org.semwebcentral.sweetrules.infrastructure
Class SweetCommandHandler

java.lang.Object
  extended byorg.semwebcentral.sweetrules.infrastructure.SweetCommandHandler

public class SweetCommandHandler
extends java.lang.Object

Handles a single line of command TODO
1) For now only KRType is considered need to enhance later on with other fields

Author:
Shashidhara K Ganjugunte, Dr. Benjamin Grosof, Mike Dean, Dr. Said Tabet, Chitravanu Neogy

Field Summary
private static java.lang.String ADD_TRANSLATOR_COMMAND
          The add translator command
private static java.lang.String EXHAUST_FORWARD_INFERENCE_COMMAND
          The exhaustive forward inference command
private static java.lang.String EXIT_COMMAND
          The exit command
private static java.lang.String HELP_COMMAND
          The help command
private static java.lang.String LOAD_COMMAND
          The command to load a knowledge base
private static java.lang.String MERGE_COMMAND
           
private static java.lang.String QUERY_COMMAND
          The query command
private static java.lang.String QUIT_COMMAND
          The quit command
private static java.lang.String SEARCH_COMPOSITE_COMMAND
          Command to search for a composite component
private static java.lang.String SEARCH_SIMPLE_COMMAND
          Command to search for a simple component
private static java.lang.String TRANSLATE_COMMAND
          The translate command
 
Constructor Summary
SweetCommandHandler()
           
 
Method Summary
private  void executeAddTranslatorCommand(java.lang.String[] commandParts)
          Dynamically adds a translator to the list of known translators
 void executeCommand(java.lang.String commandLine)
          Executes the specified command
private  void executeExhaustForwardInferenceCommand(java.lang.String[] commandParts)
          Executes exhaustive forward inferencing command NOTE: THE DIFFFACTS AND EFFECTING ARE DONE ONLY IF THE SOURCE AND TARGET ARE RULEML
private  void executeHelpCommand(java.lang.String[] commandParts)
          Executes the help command TODO: Provide more context sensitive help
private  void executeLoad(java.lang.String[] commandParts)
          Executes a load command
private  void executeMerge(java.lang.String[] commandParts)
          Executes the merge command
private  void executeQuery(java.lang.String[] commandParts)
          Executes a query command
private  void executeSearchCompositeCommand(java.lang.String[] commandParts)
          Executes the command to perform a search for composite translator
private  void executeSearchSimpleCommand(java.lang.String[] commandParts)
          Executes the command to perform a search for simple translator
private  void executeTranslation(java.lang.String[] commandParts)
          Executes the translate command
private static void generateTargetKB(ISweetKBDescriptor sourceKBDescriptor, ISweetKBDescriptor targetKBDescriptor)
          Utility function to generate the target KB while doing inferencing
private  java.lang.Object getComponentDescriptorFromParameters(java.lang.String[] commandParts)
          Retrievs the component descriptor to be searched
private  ISweetKBDescriptor getKBDescriptor(java.lang.String location, ISweetKRDescriptor krDescriptor)
          Tries to disambiguate between a URI and a file and returns the appropriate descriptor
private  java.lang.String getNewConclusions(java.lang.String sourceRuleML, java.lang.String concludedRuleML)
           
private  void print(java.lang.String message)
          The message to be printed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRANSLATE_COMMAND

private static final java.lang.String TRANSLATE_COMMAND
The translate command

See Also:
Constant Field Values

LOAD_COMMAND

private static final java.lang.String LOAD_COMMAND
The command to load a knowledge base

See Also:
Constant Field Values

QUERY_COMMAND

private static final java.lang.String QUERY_COMMAND
The query command

See Also:
Constant Field Values

EXHAUST_FORWARD_INFERENCE_COMMAND

private static final java.lang.String EXHAUST_FORWARD_INFERENCE_COMMAND
The exhaustive forward inference command

See Also:
Constant Field Values

SEARCH_SIMPLE_COMMAND

private static final java.lang.String SEARCH_SIMPLE_COMMAND
Command to search for a simple component

See Also:
Constant Field Values

SEARCH_COMPOSITE_COMMAND

private static final java.lang.String SEARCH_COMPOSITE_COMMAND
Command to search for a composite component

See Also:
Constant Field Values

HELP_COMMAND

private static final java.lang.String HELP_COMMAND
The help command

See Also:
Constant Field Values

ADD_TRANSLATOR_COMMAND

private static final java.lang.String ADD_TRANSLATOR_COMMAND
The add translator command

See Also:
Constant Field Values

EXIT_COMMAND

private static final java.lang.String EXIT_COMMAND
The exit command

See Also:
Constant Field Values

QUIT_COMMAND

private static final java.lang.String QUIT_COMMAND
The quit command

See Also:
Constant Field Values

MERGE_COMMAND

private static final java.lang.String MERGE_COMMAND
See Also:
Constant Field Values
Constructor Detail

SweetCommandHandler

public SweetCommandHandler()
Method Detail

executeCommand

public void executeCommand(java.lang.String commandLine)
                    throws SweetException
Executes the specified command

Parameters:
commandLine - The command line (command + args) to be executed
Throws:
SweetException

executeTranslation

private void executeTranslation(java.lang.String[] commandParts)
                         throws SweetException
Executes the translate command

Parameters:
commandParts - All parts of the command
Throws:
SweetException

executeLoad

private void executeLoad(java.lang.String[] commandParts)
                  throws SweetException
Executes a load command

Parameters:
commandParts - All parts of the command
Throws:
SweetException

executeQuery

private void executeQuery(java.lang.String[] commandParts)
                   throws SweetException
Executes a query command

Parameters:
commandParts - All parts of the command
Throws:
SweetException

executeExhaustForwardInferenceCommand

private void executeExhaustForwardInferenceCommand(java.lang.String[] commandParts)
                                            throws SweetException
Executes exhaustive forward inferencing command NOTE: THE DIFFFACTS AND EFFECTING ARE DONE ONLY IF THE SOURCE AND TARGET ARE RULEML

Parameters:
commandParts - The parameters for the exhaustive forward inferencing command
Throws:
SweetException

getNewConclusions

private java.lang.String getNewConclusions(java.lang.String sourceRuleML,
                                           java.lang.String concludedRuleML)
                                    throws SweetException
Throws:
SweetException

generateTargetKB

private static void generateTargetKB(ISweetKBDescriptor sourceKBDescriptor,
                                     ISweetKBDescriptor targetKBDescriptor)
                              throws SweetInferenceEngineException
Utility function to generate the target KB while doing inferencing

Parameters:
sourceKBDescriptor - The source KB descriptor
targetKBDescriptor - The target KB descriptor
Throws:
SweetInferenceEngineException - if an error occurs

executeSearchSimpleCommand

private void executeSearchSimpleCommand(java.lang.String[] commandParts)
                                 throws SweetException
Executes the command to perform a search for simple translator

Parameters:
commandParts - The parameters for the search command
Throws:
SweetException

executeSearchCompositeCommand

private void executeSearchCompositeCommand(java.lang.String[] commandParts)
                                    throws SweetException
Executes the command to perform a search for composite translator

Parameters:
commandParts - The parameters for the search command
Throws:
SweetException - if an error occurs

getComponentDescriptorFromParameters

private java.lang.Object getComponentDescriptorFromParameters(java.lang.String[] commandParts)
                                                       throws SweetException
Retrievs the component descriptor to be searched

Parameters:
commandParts - The arguments for the search command
Returns:
The component descriptor
Throws:
SweetException

executeAddTranslatorCommand

private void executeAddTranslatorCommand(java.lang.String[] commandParts)
                                  throws SweetException
Dynamically adds a translator to the list of known translators

Parameters:
commandParts - arguments to the command
Throws:
SweetException

executeMerge

private void executeMerge(java.lang.String[] commandParts)
                   throws SweetException
Executes the merge command

Parameters:
commandParts - arguments to the command
Throws:
SweetException

executeHelpCommand

private void executeHelpCommand(java.lang.String[] commandParts)
Executes the help command TODO: Provide more context sensitive help

Parameters:
commandParts -

getKBDescriptor

private ISweetKBDescriptor getKBDescriptor(java.lang.String location,
                                           ISweetKRDescriptor krDescriptor)
Tries to disambiguate between a URI and a file and returns the appropriate descriptor

Parameters:
location - The location either local file or URI
krDescriptor - The KR descriptor of the KB
Returns:
The appropriate KB descriptor

print

private void print(java.lang.String message)
The message to be printed

Parameters:
message -