org.oddjob.structural
Class ChildHelper

java.lang.Object
  extended byorg.oddjob.structural.ChildHelper
Direct Known Subclasses:
StatefulChildHelper

public class ChildHelper
extends java.lang.Object

Helper for managing child Objects. This class will track structural changes and notify listeners.

Author:
Rob Gordon

Constructor Summary
ChildHelper(java.lang.Object source)
          Constructor.
 
Method Summary
 void addChild(java.lang.Object child)
          Add a child.
 void addChildren(java.lang.Object[] children)
          Add an array of children.
 void addStructuralListener(StructuralListener listener)
           
 void destroyAll()
          Destroy all the children and remove them.
 java.lang.Object getChild()
          Return an only child.
 java.lang.Object getChildAt(int index)
          Return a child.
 java.lang.Object[] getChildren()
          Return an array of children.
static java.lang.Object[] getChildren(Structural structural)
           
 void hardResetChildren()
          Perform a hard reset.
 void insertChild(int index, java.lang.Object child)
          Insert a child.
 void removeAllChildren()
          Allows a sub class to remove all children from itself.
 void removeChild(java.lang.Object child)
          Remove a child.
 java.lang.Object removeChildAt(int index)
          Remove a child by index.
 void removeStructuralListener(StructuralListener listener)
           
 void replaceChild(java.lang.Object child, java.lang.Object replacement)
          Replace a child.
 int size()
          The number of children.
 void softResetChildren()
          Perform a soft reset.
 void stopChildren()
          Stop all the child jobs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChildHelper

public ChildHelper(java.lang.Object source)
Constructor.

Parameters:
source - The source used as the source of the event.
Method Detail

addChild

public void addChild(java.lang.Object child)
Add a child. This method fires the appropriate event in accordance with the structural interface.

Parameters:
child - A child object.

insertChild

public void insertChild(int index,
                        java.lang.Object child)
Insert a child.

Parameters:
index - The index.
child - The child.

addChildren

public void addChildren(java.lang.Object[] children)
Add an array of children.

Parameters:
children - The children.

removeChildAt

public java.lang.Object removeChildAt(int index)
Remove a child by index. This method fires the appropriate event in accordance with the Strucutral interface.

Parameters:
index - The index of the child to remove.
Returns:
The child removed.

removeChild

public void removeChild(java.lang.Object child)
Remove a child. This method fires the appropriate event in accordance with the Strucutral interface.

Parameters:
child - The child to remove.

replaceChild

public void replaceChild(java.lang.Object child,
                         java.lang.Object replacement)
Replace a child. This method fires the appropriate event in accordance with the Strucutral interface.

Parameters:
child - The child to remove.
replacement - The child to replace.

removeAllChildren

public void removeAllChildren()
Allows a sub class to remove all children from itself. This method fires the appropriate events in accordance with the structural interface.

This meothod doesn't destroy children. It may be more appropriate to use destroyAll.


stopChildren

public void stopChildren()
Stop all the child jobs. This is a convienicne method that sub classes can choose to use if required.


softResetChildren

public void softResetChildren()
Perform a soft reset. This method propergates the soft reset message down to all child jobs. This is a convenience method that a sub class can choose to use.


hardResetChildren

public void hardResetChildren()
Perform a hard reset. This method propergates the hard reset message down to all child jobs. This is a convenience method a sub class can choose to use.


getChildren

public java.lang.Object[] getChildren()
Return an array of children.

Returns:
An array of child objects.

getChildAt

public java.lang.Object getChildAt(int index)
Return a child.

Returns:
A child.

getChild

public java.lang.Object getChild()
Return an only child.

Returns:
A child.

addStructuralListener

public void addStructuralListener(StructuralListener listener)

removeStructuralListener

public void removeStructuralListener(StructuralListener listener)

size

public int size()
The number of children.

Returns:
The number of children.

destroyAll

public void destroyAll()
Destroy all the children and remove them.


getChildren

public static java.lang.Object[] getChildren(Structural structural)