net.nexttext.behaviour.control
Class Repeat

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

public class Repeat
extends AbstractAction

Repeats an action for a fixed number of times, then stops that action.

The repeat count is incremented whenever the called Action can't complete but returns an event, or when it does complete. Repeat will return event in the ActionResult when the count is incremented, and complete when it reaches its repeat count.

Repeat will have no effect when used with an action that does not return events or complete.

XXXBUG: how could we identify a "Countable" object explicitly?


Nested Class Summary
 
Nested classes/interfaces inherited from interface net.nexttext.behaviour.Action
Action.ActionResult
 
Constructor Summary
Repeat(Action action)
          Repeat an action indefinitely.
Repeat(Action action, int repetitions)
          Repeat an action a certain amount of repetitions.
 
Method Summary
 Action.ActionResult behave(TextObject to)
          See class description.
 java.util.Map<java.lang.String,Property> getRequiredProperties()
          The properties that this action requires on a TextObject.
 
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

Repeat

public Repeat(Action action)
Repeat an action indefinitely.

Parameters:
action - the action to repeat

Repeat

public Repeat(Action action,
              int repetitions)
Repeat an action a certain amount of repetitions.

Parameters:
action - the action to repeat
repetitions - the number of times to repeat, use 0 to repeat forever
Method Detail

behave

public Action.ActionResult behave(TextObject to)
See class description.

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

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