com.sdm.quasar.client.core.commands
Class GenericCommandManager

java.lang.Object
  extended bycom.sdm.quasar.client.core.commands.RunnableCommandManager
      extended bycom.sdm.quasar.client.core.commands.GenericCommandManager
All Implemented Interfaces:
CommandManager

public class GenericCommandManager
extends RunnableCommandManager

A generic implementation of CommandManager, that can call any public method (by reflection). The enablement state must be provided by the user of this class.

Version:
1.0
Author:
Thomas Wolf

Constructor Summary
GenericCommandManager()
          Creates a new GenericCommandManager.
 
Method Summary
 void registerCommand(java.lang.String commandId, java.lang.Object target, java.lang.Class targetClass, java.lang.String methodName, BooleanState enabledBooleanState)
          Registers a new command with the given id and parameters to this GenericCommandManager.
 void registerCommand(java.lang.String commandId, java.lang.Object target, java.lang.reflect.Method method, BooleanState enabledBooleanState)
          Registers a new command with the given id and parameters to this GenericCommandManager.
 void registerCommand(java.lang.String name, java.lang.Object target, java.lang.String methodName, BooleanState enabledBooleanState)
          Registers a new command with the given id and parameters to this GenericCommandManager.
 
Methods inherited from class com.sdm.quasar.client.core.commands.RunnableCommandManager
getCommand, hasCommand, registerCommand, setEnabledBooleanState, unregisterCommand
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericCommandManager

public GenericCommandManager()
Creates a new GenericCommandManager.

Method Detail

registerCommand

public void registerCommand(java.lang.String commandId,
                            java.lang.Object target,
                            java.lang.reflect.Method method,
                            BooleanState enabledBooleanState)
Registers a new command with the given id and parameters to this GenericCommandManager.

Parameters:
commandId - the command id for the command (not null)
target - the target object instance to execute a method of (may be null, then the method to execute should be static)
method - the Method beeing executed on the target object (not null)
enabledBooleanState - an enabled state (may be null; this means the command is always enabled)
Throws:
java.lang.IllegalArgumentException - if command id or method is null or if the given method cannot be executed on the given target object

registerCommand

public void registerCommand(java.lang.String commandId,
                            java.lang.Object target,
                            java.lang.Class targetClass,
                            java.lang.String methodName,
                            BooleanState enabledBooleanState)
Registers a new command with the given id and parameters to this GenericCommandManager.

Parameters:
commandId - the command id for the command (not null)
target - the target object instance to execute a method of (may be null, then the method to execute should be static)
targetClass - the Class of the target object to execute a method of (not null)
methodName - the name of the method beeing execute (not null, should be a method name of the target class). The method must take no arguments.
enabledBooleanState - an enabled state (may be null; this means the command is always enabled)

registerCommand

public void registerCommand(java.lang.String name,
                            java.lang.Object target,
                            java.lang.String methodName,
                            BooleanState enabledBooleanState)
Registers a new command with the given id and parameters to this GenericCommandManager.

Parameters:
target - the target object instance to execute a method of (not null)
methodName - the name of the method beeing execute (not null, should be a method name of the target's class). The method must take no arguments.
enabledBooleanState - an enabled state (may be null; this means the command is always enabled)