org.jagatoo.commands
Class CommandProcessor

java.lang.Object
  extended by org.jagatoo.commands.CommandProcessor

public class CommandProcessor
extends java.lang.Object

Processes command lines and extracts a CommandLine object from it.


Constructor Summary
CommandProcessor(LogChannel logChannel)
          Creates a new CommandProcessor.
CommandProcessor(LogChannel logChannel, Command[] availableCommands)
          Creates a new CommandProcessor.
CommandProcessor(LogChannel logChannel, java.util.List<Command> availableCommands)
          Creates a new CommandProcessor.
 
Method Summary
 void bindCommand(DeviceComponent comp, InputActionCommand command)
          Binds a Command to a keyboard-key or mouse-button action.
<C extends InputActionCommand>
void
bindCommands(InputBindingsManager<C> bindingsManager)
          Binds all InputActionCommands to a keyboard-key or mouse-button action.
 InputListener getInputListener()
           
 LogChannel getLogChannel()
           
 Command getRegisteredCommand(java.lang.String key)
           
 Command[] getRegisteredCommands()
           
 void processLine(java.lang.String line)
          Processes a command line and invokes the bound Command.
 Command registerCommand(Command command)
          Registers a Command to be handled by the CommandProcessor.
 void registerCommands(Command[] commands)
          Registers a list of Commands to be handled by the CommandProcessor.
 void registerCommands(java.util.List<? extends Command> commands)
          Registers a list of Commands to be handled by the CommandProcessor.
 void unbindAll()
          Unbinds all.
 void unbindCommand(DeviceComponent comp, InputActionCommand command)
          Unbinds a Command from a keyboard-key or mouse-button action.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandProcessor

public CommandProcessor(LogChannel logChannel)
Creates a new CommandProcessor.

Parameters:
logChannel - the LogChannel, which responses are logged to.

CommandProcessor

public CommandProcessor(LogChannel logChannel,
                        Command[] availableCommands)
Creates a new CommandProcessor.

Parameters:
logChannel - the LogChannel, which responses are logged to.
availableCommands -

CommandProcessor

public CommandProcessor(LogChannel logChannel,
                        java.util.List<Command> availableCommands)
Creates a new CommandProcessor.

Parameters:
logChannel - the LogChannel, which responses are logged to.
availableCommands -
Method Detail

getLogChannel

public final LogChannel getLogChannel()
Returns:
the LogChannel, which responses are logged to.

getRegisteredCommands

public Command[] getRegisteredCommands()
Returns:
an array of all registered Commands.

getRegisteredCommand

public Command getRegisteredCommand(java.lang.String key)
Returns:
the Command registered with that key.

getInputListener

public final InputListener getInputListener()
Returns:
the InputListener, that has to be registered to the InputManager.

registerCommand

public final Command registerCommand(Command command)
Registers a Command to be handled by the CommandProcessor.

Parameters:
command -

registerCommands

public final void registerCommands(java.util.List<? extends Command> commands)
Registers a list of Commands to be handled by the CommandProcessor.

Parameters:
commands -

registerCommands

public final void registerCommands(Command[] commands)
Registers a list of Commands to be handled by the CommandProcessor.

Parameters:
commands -

bindCommand

public void bindCommand(DeviceComponent comp,
                        InputActionCommand command)
Binds a Command to a keyboard-key or mouse-button action.

Parameters:
comp -
command -

bindCommands

public <C extends InputActionCommand> void bindCommands(InputBindingsManager<C> bindingsManager)
Binds all InputActionCommands to a keyboard-key or mouse-button action.

Parameters:
bindingsManager -

unbindCommand

public void unbindCommand(DeviceComponent comp,
                          InputActionCommand command)
Unbinds a Command from a keyboard-key or mouse-button action.

Parameters:
comp -
command -
See Also:
KeyCode#getKeyName(int), MouseCode#getButtonName(int)

unbindAll

public void unbindAll()
Unbinds all.


processLine

public void processLine(java.lang.String line)
Processes a command line and invokes the bound Command.

Parameters:
line -