net.nexttext.behaviour.control
Class Selector

java.lang.Object
  extended by net.nexttext.behaviour.AbstractAction
      extended by net.nexttext.behaviour.control.Selector
All Implemented Interfaces:
Action

public class Selector
extends AbstractAction

This action maintains a collection of action (in form of a HashMap) in which any one of the contained actions can be set to act as the current action.

TextObjects are passed on to (and only to) the current action. This allows for the creation of behaviours with state, i.e. behaviours that display different dynamics at different times. For each action contained in the selector a collection of textObjects that the action has finished processing is maintained. This maintains the 'completed' semantics of contained actions but allows textObjects to continually be acted upon when the current action changes.


Nested Class Summary
 
Nested classes/interfaces inherited from interface net.nexttext.behaviour.Action
Action.ActionResult
 
Constructor Summary
Selector()
           
 
Method Summary
 void add(java.lang.String name, Action action)
          Add an action to the selector
 Action.ActionResult behave(TextObject to)
          Applies the current action
 java.lang.Object[] getActionNames()
           
 java.util.Map<java.lang.String,Property> getRequiredProperties()
          The properties that this action requires on a TextObject.
 void select(java.lang.String name)
          If [name] matches the name of a previously added action then that action will be made the current action
 
Methods inherited from class net.nexttext.behaviour.AbstractAction
behave, behave, complete, getDisplayName, makeBehaviour, properties, setDisplayName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Selector

public Selector()
Method Detail

select

public void select(java.lang.String name)
If [name] matches the name of a previously added action then that action will be made the current action

Parameters:
name - - the name of the action to be selected.

add

public void add(java.lang.String name,
                Action action)
Add an action to the selector

Parameters:
name -
action -

behave

public Action.ActionResult behave(TextObject to)
Applies the current action

Specified by:
behave in interface Action
Overrides:
behave in class AbstractAction
Returns:
ActionResult(false, false, true) if the current action completes or signals an event. Else returns ActionResult(false, false, false)

getActionNames

public java.lang.Object[] getActionNames()

getRequiredProperties

public java.util.Map<java.lang.String,Property> getRequiredProperties()
Description copied from class: AbstractAction
The properties that this action requires on a TextObject.

Right now this method always returns an empty map, since basic Actions should be restricted to use only the core set of TextObject properties.

If a subclass of Action requires a set of additional properties then it should override this method and return the appropriate Map containing the property objects.

This method is required by the Action interface.

Specified by:
getRequiredProperties in interface Action
Overrides:
getRequiredProperties in class AbstractAction