net.nexttext.behaviour
Class Behaviour

java.lang.Object
  extended by net.nexttext.behaviour.AbstractBehaviour
      extended by net.nexttext.behaviour.Behaviour

public class Behaviour
extends AbstractBehaviour

Basic Behaviour class.

Behaviours are used by the Book, to apply Actions to a set of TextObjects.

When the Action indicates that the processing of that object is complete the object is removed from the Behaviour's set of TextObjects.


Constructor Summary
Behaviour(Action action)
          Creates a Behaviour which will perform the specified action.
 
Method Summary
 void addObject(TextObject to)
          Add a TextObject to this Behaviour's list of objects to act on.
 void behaveAll()
          Calls behave() on every object in its list.
 void removeObject(TextObject to)
          Stop this behaviour from acting on a TextObject.
 
Methods inherited from class net.nexttext.behaviour.AbstractBehaviour
getDisplayName, setDisplayName, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Behaviour

public Behaviour(Action action)
Creates a Behaviour which will perform the specified action.

Method Detail

behaveAll

public void behaveAll()
Calls behave() on every object in its list.

Objects will be removed from the list if the Action completes.

Specified by:
behaveAll in class AbstractBehaviour

addObject

public void addObject(TextObject to)
Description copied from class: AbstractBehaviour
Add a TextObject to this Behaviour's list of objects to act on.

Each Action requires a specific set of properties in TextObjects that it acts on. These properties are added to the TextObjects when they are added to a behaviour for each Action which is a part of that behaviour. Subclasses of AbstractBehaviour have to be sure to perform this necessary step, by overriding this method, (but don't forget to call super.addObject()). Behaviour provides a good example of how to do this.

If the TextObject is already in the set, nothing will be done, a single remove will still remove the object from the list.

Overrides:
addObject in class AbstractBehaviour

removeObject

public void removeObject(TextObject to)
Stop this behaviour from acting on a TextObject.

Overrides:
removeObject in class AbstractBehaviour