com.virtuosotechnologies.lib.command
Class AbstractCommandNode

java.lang.Object
  extended bycom.virtuosotechnologies.lib.container.PseudoModifiablePropertySet
      extended bycom.virtuosotechnologies.lib.container.BasicModifiablePropertySet
          extended bycom.virtuosotechnologies.lib.command.AbstractCommandNode
All Implemented Interfaces:
CommandListener, CommandNode, EventListener, ModifiablePropertySet, PropertySet
Direct Known Subclasses:
BasicCommandNode

public abstract class AbstractCommandNode
extends BasicModifiablePropertySet
implements CommandNode

Base class for implementations of CommandNode. Uses a BasicModifiablePropertySet, and implements all methods except commandInvoked() and getFlavor().


Field Summary
 
Fields inherited from interface com.virtuosotechnologies.lib.command.CommandListener
COMMAND_INVOKED_METHOD
 
Constructor Summary
protected AbstractCommandNode()
          Constructor.
protected AbstractCommandNode(PropertySet defaultProperties)
          Constructor.
 
Method Summary
 void addChild(CommandNode child)
          Add a child node
 void addNodeListener(CommandNodeListener listener)
          Add listener for node hierarchy events
protected  void fireAllChildrenRemovedEvent()
          Fires an allChildrenRemoved event
protected  void fireChildAddedEvent(CommandNode child, int index)
          Fires a childAdded event
protected  void fireChildRemovedEvent(CommandNode child, int index)
          Fires a childRemoved event
 int getIndexOfChild(CommandNode child)
          Get the index of the given child node, or -1 if the child is not found.
 CommandNode getNthChild(int index)
          Get the indexed child
 int getNumChildren()
          Get the number of children
 void insertChild(int index, CommandNode child)
          Insert a child node at the given index
static void invoke(CommandNode node)
          Fire an invoke event.
 boolean isChild(CommandNode child)
          Is the given node a child of this node
 void removeAllChildren()
          Remove all children
 void removeNodeListener(CommandNodeListener listener)
          Remove listener for node hierarchy events
 void removeNthChild(int index)
          Remove a child node
 
Methods inherited from class com.virtuosotechnologies.lib.container.PseudoModifiablePropertySet
addPropertySetListener, firePropertySetEvent, getDefaultValue, getValue, putValue, removePropertySetListener, resetValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.virtuosotechnologies.lib.command.CommandNode
getFlavor
 
Methods inherited from interface com.virtuosotechnologies.lib.container.ModifiablePropertySet
putValue, resetValue
 
Methods inherited from interface com.virtuosotechnologies.lib.container.PropertySet
addPropertySetListener, getDefaultValue, getValue, removePropertySetListener
 
Methods inherited from interface com.virtuosotechnologies.lib.command.CommandListener
commandInvoked
 

Constructor Detail

AbstractCommandNode

protected AbstractCommandNode()
Constructor.


AbstractCommandNode

protected AbstractCommandNode(PropertySet defaultProperties)
Constructor.

Parameters:
defaultProperties - defaults for PropertySet.
Method Detail

addNodeListener

public void addNodeListener(CommandNodeListener listener)
Add listener for node hierarchy events

Specified by:
addNodeListener in interface CommandNode
Parameters:
listener - listener to add

removeNodeListener

public void removeNodeListener(CommandNodeListener listener)
Remove listener for node hierarchy events

Specified by:
removeNodeListener in interface CommandNode
Parameters:
listener - listener to remove

fireChildAddedEvent

protected void fireChildAddedEvent(CommandNode child,
                                   int index)
Fires a childAdded event

Parameters:
child - child added
index - where the child was added

fireChildRemovedEvent

protected void fireChildRemovedEvent(CommandNode child,
                                     int index)
Fires a childRemoved event

Parameters:
child - child removed
index - where the child was removed from

fireAllChildrenRemovedEvent

protected void fireAllChildrenRemovedEvent()
Fires an allChildrenRemoved event


addChild

public void addChild(CommandNode child)
Add a child node

Specified by:
addChild in interface CommandNode
Parameters:
child - CommandNode to add

insertChild

public void insertChild(int index,
                        CommandNode child)
Insert a child node at the given index

Specified by:
insertChild in interface CommandNode
Parameters:
index - 0-based index indicating where to add the node
child - CommandNode to add
Throws:
IndexOutOfBoundsException - the index was out of bounds

getNthChild

public CommandNode getNthChild(int index)
Get the indexed child

Specified by:
getNthChild in interface CommandNode
Parameters:
index - 0-based index indicating which child to get
Returns:
child at that index
Throws:
IndexOutOfBoundsException - the index was out of bounds

getNumChildren

public int getNumChildren()
Get the number of children

Specified by:
getNumChildren in interface CommandNode
Returns:
number of children.

removeNthChild

public void removeNthChild(int index)
Remove a child node

Specified by:
removeNthChild in interface CommandNode
Parameters:
index - 0-based index indicating which child to remove
Throws:
IndexOutOfBoundsException - the index was out of bounds

removeAllChildren

public void removeAllChildren()
Remove all children

Specified by:
removeAllChildren in interface CommandNode

isChild

public boolean isChild(CommandNode child)
Is the given node a child of this node

Parameters:
child - child to test
Returns:
true if child is a child of this node, otherwise false

getIndexOfChild

public int getIndexOfChild(CommandNode child)
Get the index of the given child node, or -1 if the child is not found.

Parameters:
child - child node
Returns:
the 0-based index, or -1 if the child is not found

invoke

public static void invoke(CommandNode node)
Fire an invoke event.

Parameters:
node - node to invoke