ikrs.util
Interface CommandFactory<C extends Command>

All Known Implementing Classes:
AbstractCommandFactory, DefaultCommandFactory, ModuleCommandFactory, YuccaCommandFactory

public interface CommandFactory<C extends Command>

This is a factory class to create Command instances. Some CommandFactories might also be capable to parse Commands from a given String.


Method Summary
 CommandFactory<C> getParentFactory()
          Get the parent factory for this factory.
 java.util.Set<C> getSupportedCommands()
          Get a set of all supported commands.
 C make(java.lang.String name, BasicType[] params)
          Make a new Command with the given name and params.
 C make(java.lang.String name, java.lang.String[] params)
          Make a new Command with the given name and params.
 C parse(java.lang.String str)
          Make a new Command by parsing it from a string.
 void setParentFactory(CommandFactory<C> newParent)
          Set the parent factory for this factory.
 

Method Detail

getSupportedCommands

java.util.Set<C> getSupportedCommands()
Get a set of all supported commands. This is usually a set of the commands that are understood by this factory plus all commands that are understood by all parent factories (if exist).

Returns:
A set containting all commands that are supported by this factory.

getParentFactory

CommandFactory<C> getParentFactory()
Get the parent factory for this factory. If there is no parent factory present the method returns null.

Returns:
The parent factory or null if no such exists.

setParentFactory

void setParentFactory(CommandFactory<C> newParent)
Set the parent factory for this factory. Pass null to clear the parent factory.

Parameters:
The - new parent factory or null to clear.

make

C make(java.lang.String name,
       java.lang.String[] params)
                       throws UnknownCommandException,
                              CommandStringIncompleteException
Make a new Command with the given name and params.

Parameters:
name - The command's name.
params - The command's params - in string representation.
Returns:
The new command.
Throws:
UnknownCommandException
CommandStringIncompleteException

make

C make(java.lang.String name,
       BasicType[] params)
                       throws UnknownCommandException,
                              CommandStringIncompleteException
Make a new Command with the given name and params.

Parameters:
name - The command's name.
params - The command's params - in BasicType representation.
Returns:
The new command.
Throws:
UnknownCommandException
CommandStringIncompleteException

parse

C parse(java.lang.String str)
                        throws java.lang.UnsupportedOperationException,
                               UnknownCommandException,
                               CommandStringIncompleteException,
                               java.text.ParseException
Make a new Command by parsing it from a string. Some command classes might not support this method as the parsing process would be too complex. In this case an UnsupportedOperationException is thrown.

Parameters:
str - The string to parse the command from.
Returns:
The new command.
Throws:
java.lang.UnsupportedOperationException - if the underlying command implementation does not support parsing.
CommandStringIncompleteException - If the given String lacks some data at the end.
java.text.ParseException - If the given String is malformed.
UnknownCommandException