com.cometway.states
Class ReflectionTransition

java.lang.Object
  extended by com.cometway.states.ReflectionTransition
All Implemented Interfaces:
TransitionInterface

public class ReflectionTransition
extends java.lang.Object
implements TransitionInterface

This implementation of TransitionInterface uses the Java Reflection API to execute a specific method on the transition object. The transition object's method an Object parameter, and returns the name of the new State if the translation was successful; false otherwise.


Constructor Summary
ReflectionTransition(java.lang.String name, java.lang.Object objRef, java.lang.String methodName)
          Constructor for this transition.
 
Method Summary
 java.lang.String execute()
          Executes the transition for the specified object returning the name of the new State if the transition was successful; null otherwise.
 java.lang.String getName()
          Returns the name of this transition.
 java.lang.String toString()
          Returns a String representative of this transition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReflectionTransition

public ReflectionTransition(java.lang.String name,
                            java.lang.Object objRef,
                            java.lang.String methodName)
Constructor for this transition.

Parameters:
name - Name of this transition.
methodName - Name of the method to call on the transition object to execute the transition.
Method Detail

execute

public java.lang.String execute()
                         throws TransitionException
Executes the transition for the specified object returning the name of the new State if the transition was successful; null otherwise. This implementation uses the Java Reflection API to make a method call on the specified object to execute the transition.

Specified by:
execute in interface TransitionInterface
Throws:
TransitionException - if there is a problem executing the transition.

getName

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

Specified by:
getName in interface TransitionInterface

toString

public java.lang.String toString()
Returns a String representative of this transition.

Overrides:
toString in class java.lang.Object