com.cometway.states
Class ReflectionCommand

java.lang.Object
  extended by com.cometway.states.ReflectionCommand
All Implemented Interfaces:
CommandInterface

public class ReflectionCommand
extends java.lang.Object
implements CommandInterface

This implementation of CommandInterface using the reflection API to invoke a public method of any Object.


Constructor Summary
ReflectionCommand(java.lang.String name, java.lang.Object objRef, java.lang.String methodName)
          Constructor for this class.
 
Method Summary
 void execute()
          Executes this command.
 java.lang.String getName()
          Returns the name of this command.
 java.lang.String toString()
          Returns the String representation of this command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReflectionCommand

public ReflectionCommand(java.lang.String name,
                         java.lang.Object objRef,
                         java.lang.String methodName)
Constructor for this class.

Parameters:
name - the name of this command.
objRef - a reference to the Object whose method will be invoked
methodName - name of the method that will be invoked (method must not have any parameters)
Method Detail

execute

public void execute()
             throws CommandException
Executes this command.

Specified by:
execute in interface CommandInterface
Throws:
CommandException - There was a problem executing the command.

getName

public java.lang.String getName()
Returns the name of this command.

Specified by:
getName in interface CommandInterface

toString

public java.lang.String toString()
Returns the String representation of this command.

Overrides:
toString in class java.lang.Object