package com.obidea.semantika.cli2.runtime;

import java.util.HashMap;
import java.util.Map;

import com.obidea.semantika.cli2.command.Command;
import com.obidea.semantika.cli2.command.CommandFactory;
import com.obidea.semantika.cli2.command.SelectCommand;
import com.obidea.semantika.cli2.command.SetPrefixCommand;
import com.obidea.semantika.cli2.command.ShowPrefixesCommand;
import com.obidea.semantika.knowledgebase.IPrefixManager;
import com.obidea.semantika.queryanswer.IQueryEngine;

public class ConsoleSession
{
   private IQueryEngine mQueryEngine;
   private Map<String, String> mPrefixMapper;

   public ConsoleSession(IQueryEngine engine, IPrefixManager prefixManager)
   {
      mQueryEngine = engine;
      mPrefixMapper = new HashMap<String, String>(prefixManager.getPrefixMapper());
   }

   public void start() throws Exception
   {
      mQueryEngine.start();
   }

   public Object execute(String command) throws Exception
   {
      Command cmd = CommandFactory.create(command);
      if (cmd instanceof SelectCommand) {
         return mQueryEngine.evaluate(cmd.arguments().get("string"));
      }
      else if (cmd instanceof SetPrefixCommand) {
         mPrefixMapper.put(cmd.arguments().get("prefix"), cmd.arguments().get("namespace"));
      }
      else if (cmd instanceof ShowPrefixesCommand) {
         return mPrefixMapper;
      }
      throw new Exception();
   }

   public void destroy() throws Exception
   {
      mQueryEngine.stop();
   }
}

@@ -598,16 +598,46 @@
 apper;%0A%0A
+   private Command mCommand;%0A%0A
    publi
@@ -976,24 +976,25 @@
 %7B%0A      
+m
 Command 
 cmd = Co
@@ -985,20 +985,16 @@
 Command 
-cmd 
 = Comman
@@ -1025,26 +1025,31 @@
 ;%0A      if (
-c
 m
+Comman
 d instanceof
@@ -1104,18 +1104,23 @@
 valuate(
-c
 m
+Comman
 d.argume
@@ -1156,34 +1156,39 @@
 %0A      else if (
-c
 m
+Comman
 d instanceof Set
@@ -1231,18 +1231,23 @@
 per.put(
-c
 m
+Comman
 d.argume
@@ -1267,18 +1267,23 @@
 efix%22), 
-c
 m
+Comman
 d.argume
@@ -1334,10 +1334,15 @@
 if (
-c
 m
+Comman
 d in
@@ -1439,32 +1439,97 @@
 eption();%0A   %7D%0A%0A
+   public Command getCommand()%0A   %7B%0A      return mCommand;%0A   %7D%0A%0A
    public void d

Add method to get the command object.