com.dynamide.util
Class CompositeAbstract

java.lang.Object
  extended by com.dynamide.util.CompositeAbstract
All Implemented Interfaces:
IComposite
Direct Known Subclasses:
Composite, CompositeArray

public abstract class CompositeAbstract
extends java.lang.Object
implements IComposite

Composite is the base class for any item found in a tree structure. A composite can own child Composites. A Composite has a name, and any named attributes. Attributes are Objects. The special attribute 'name' is just a String. A top level Composite will not have a parent.

Author:
Laramie Crocker

Nested Class Summary
 class CompositeAbstract.DumpWalker
           
 
Field Summary
static int ATTRIBUTE_NOT_FOUND
           
static int ATTRIBUTES_CHANGED
           
static int CHILDREN_CHANGED
           
static int NAME_CHANGED
           
 
Constructor Summary
CompositeAbstract(java.lang.String name, IComposite parent)
           
 
Method Summary
abstract  void addAttribute(java.lang.String attribute_name, java.lang.Object attribute_value)
           
 void addChangeListener(ICompositeChangeListener new_listener)
           
abstract  IComposite addChild(IComposite new_child)
          Normally, you wouldn't call addChild from user classes.
abstract  java.lang.Object attributeByName(java.lang.String attributeName)
           
 void detach()
           
 java.lang.String dump()
           
 java.lang.String dump(boolean dumpPath, boolean dumpAttributes, boolean dumpIndent, boolean preorder, boolean html)
           
 java.lang.String dumpHTML()
           
 java.lang.String dumpPath()
           
 void finalize()
           
abstract  IComposite findComposite(java.lang.String itemName)
           
 java.lang.Object get(java.lang.String what)
           
abstract  java.util.Collection getAttributes()
           
abstract  java.util.Map getAttributesMap()
           
abstract  int getChildCount()
           
abstract  java.util.Collection getChildren()
           
 int getDepth()
           
 java.lang.String getName()
           
 IComposite getParent()
           
 IComposite getRoot()
           
protected  void notifyChangeListeners(int whatChanged, IComposite node)
           
 java.lang.String printAttributes()
           
 void removeChangeListener(ICompositeChangeListener listener)
           
abstract  IComposite removeChild(IComposite old_child)
           
 void setName(java.lang.String new_name)
           
 IComposite setParent(IComposite parent)
           
 java.lang.String toString()
           
 void walk(ICompositeWalker caller, int order)
          Use values of ICompositeWalker.PREORDER or ICompositeWalker.POSTORDER for order.
 void walkPostOrder(ICompositeWalker caller)
           
 void walkPreOrder(ICompositeWalker caller)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ATTRIBUTE_NOT_FOUND

public static final int ATTRIBUTE_NOT_FOUND
See Also:
Constant Field Values

NAME_CHANGED

public static final int NAME_CHANGED
See Also:
Constant Field Values

CHILDREN_CHANGED

public static final int CHILDREN_CHANGED
See Also:
Constant Field Values

ATTRIBUTES_CHANGED

public static final int ATTRIBUTES_CHANGED
See Also:
Constant Field Values
Constructor Detail

CompositeAbstract

public CompositeAbstract(java.lang.String name,
                         IComposite parent)
Method Detail

finalize

public void finalize()
              throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

getRoot

public IComposite getRoot()
Specified by:
getRoot in interface IComposite

getParent

public IComposite getParent()
Specified by:
getParent in interface IComposite

detach

public void detach()

getName

public java.lang.String getName()
Specified by:
getName in interface IComposite

setName

public void setName(java.lang.String new_name)

dumpPath

public java.lang.String dumpPath()
Specified by:
dumpPath in interface IComposite

dump

public java.lang.String dump()
Specified by:
dump in interface IComposite

dumpHTML

public java.lang.String dumpHTML()
Specified by:
dumpHTML in interface IComposite

dump

public java.lang.String dump(boolean dumpPath,
                             boolean dumpAttributes,
                             boolean dumpIndent,
                             boolean preorder,
                             boolean html)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

get

public java.lang.Object get(java.lang.String what)
Specified by:
get in interface IComposite

getDepth

public int getDepth()
Specified by:
getDepth in interface IComposite

setParent

public IComposite setParent(IComposite parent)
                     throws java.lang.Exception
Specified by:
setParent in interface IComposite
Throws:
java.lang.Exception

addChild

public abstract IComposite addChild(IComposite new_child)
                             throws java.lang.Exception
Normally, you wouldn't call addChild from user classes. Just call the constructor (String name, Composite parent). This sets the parent and adds the child to the tree.

Specified by:
addChild in interface IComposite
Throws:
java.lang.Exception

getChildren

public abstract java.util.Collection getChildren()
Specified by:
getChildren in interface IComposite
Returns:
An Enumeration of all direct children of this Composite.

getChildCount

public abstract int getChildCount()

removeChild

public abstract IComposite removeChild(IComposite old_child)
Specified by:
removeChild in interface IComposite

findComposite

public abstract IComposite findComposite(java.lang.String itemName)
                                  throws java.lang.Exception
Specified by:
findComposite in interface IComposite
Throws:
java.lang.Exception

addAttribute

public abstract void addAttribute(java.lang.String attribute_name,
                                  java.lang.Object attribute_value)
Specified by:
addAttribute in interface IComposite

attributeByName

public abstract java.lang.Object attributeByName(java.lang.String attributeName)
Returns:
The attribute with the requested name, or null if not found.

getAttributesMap

public abstract java.util.Map getAttributesMap()

getAttributes

public abstract java.util.Collection getAttributes()
Specified by:
getAttributes in interface IComposite

printAttributes

public java.lang.String printAttributes()
Specified by:
printAttributes in interface IComposite

addChangeListener

public void addChangeListener(ICompositeChangeListener new_listener)

removeChangeListener

public void removeChangeListener(ICompositeChangeListener listener)

notifyChangeListeners

protected void notifyChangeListeners(int whatChanged,
                                     IComposite node)
Parameters:
whatChanged - - one of: NAME_CHANGED,CHILDREN_CHANGED, ATTRIBUTES_CHANGED.

walkPreOrder

public void walkPreOrder(ICompositeWalker caller)

walkPostOrder

public void walkPostOrder(ICompositeWalker caller)

walk

public void walk(ICompositeWalker caller,
                 int order)
Description copied from interface: IComposite
Use values of ICompositeWalker.PREORDER or ICompositeWalker.POSTORDER for order.

Specified by:
walk in interface IComposite


Copyright © 2001-2013 DYNAMIDE.COM. All Rights Reserved.