net.sourceforge.esw.graph
Interface INode

All Superinterfaces:
java.lang.Cloneable, ICloneable, ISupportObject, java.io.Serializable
All Known Subinterfaces:
IMetaCollection, IPropertyAggregator, IPropertySource
All Known Implementing Classes:
ANodeDecorator, Node

public interface INode
extends ISupportObject, ICloneable, java.io.Serializable

Provides a universal, graph based, generic data structure.

This is a Node within the graph data structure.

An INode instance contains an identifer and value. It also provides a named, ordered list of children that can be accessed by either identifer or index. The index of the children is 0 based. An INode instance also contains a list of its parents within the graph structure.

The clone, equals, hashCode, and iterator methods all operate shallowly. That is, they only look to this INode instance for their operations. For deep operations on an INode instance and its children, see the net.sourceforge.esw.graph.decorators package.

Since INode inhereits ISupportObject abilities, INode methods that change any value of an INode instance must fire a PropertyChangeEvent with a property name of the property being changed.

When creating an INode implementor, you must also provide an equals and hashCode methods per the java.lang.Object's equals and hashCode method contracts. The default Object implementations do not provide a rich enough definition for equality among INode instances. It also provides a property scratchpad to store information related to this INode instance. Properties are name/value pairs.

To create an instance of this INode, see NodeFactory.createNode().

Examples:

    INode node = NodeFactory.createNode();
 

See Also:
IGraphVisitor, ISupportObject, NodeFactory, Object.equals(java.lang.Object), Object.hashCode()

Method Summary
 void acceptVisitor(IGraphVisitor aVisitor)
          Requests that this INode instance accept the specified IGraphVisitor instance and that visiting of this INode struture begin.
 void add(INode aNode)
          Appends the specified INode child instance to the end of this INode instances child collection.
 void add(INode aNode, boolean bAddParent)
          Appends the specified INode child instance to the end of this INode instance's child collection.
 void addParent(INode aParent)
          Sets the parent INode instance for this INode instance.
 void clear()
          Removes the children from this INode instance.
 boolean containsID(java.lang.Object aId)
          Indicates whether this INode instance contains the specified identifer as a child of this INode instance.
 INode get(int aIndex)
          Returns the INode child instance at the specified index.
 INode get(java.lang.Object aId)
          Returns the first INode child instance that contains specified identifer.
 java.util.List getList(java.lang.Object aId)
          Returns the List of INode child instances with the specified identifer.
 java.util.Iterator getParents()
          Returns an Iterator over the INode parent instances of this INode instance.
 java.lang.Object getValue()
          Returns the value of this INode instance
 boolean isEmpty()
          Indicates whether this INode instance has no children.
 java.util.Iterator iterator()
          Returns an Iterator over this INode instance's children.
 void remove(INode aNode)
          Removes the INode child instance for the specified identifer from this INode instance if present.
 void removeParent(INode aParent)
          Removes the specified parent INode instance from this INode instance.
 void setValue(java.lang.Object aValue)
          Sets the value for this INode instance.
 int size()
          Returns the number of children in this INode instance.
 
Methods inherited from interface net.sourceforge.esw.util.ISupportObject
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getID, getProperty, getPropertySize, propertyKeys, removeProperty, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener, setID, setProperty
 
Methods inherited from interface net.sourceforge.esw.util.ICloneable
clone
 

Method Detail

getValue

public java.lang.Object getValue()
Returns the value of this INode instance
Returns:
the value of this INode instance.
See Also:
setValue(Object)

setValue

public void setValue(java.lang.Object aValue)
Sets the value for this INode instance.

Fires an INodeResources.VALUE_PROPERTY property change event.

Parameters:
aValue - the value for this INode instance.
See Also:
getValue()

size

public int size()
Returns the number of children in this INode instance. If the INode contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
Returns:
the number of children in this INode instance.
See Also:
isEmpty()

isEmpty

public boolean isEmpty()
Indicates whether this INode instance has no children.
Returns:
true if this INode instance contains no children.
See Also:
size()

clear

public void clear()
Removes the children from this INode instance.

Fires an INodeResources.CLEAR_PROPERTY property change event only if there were children that were cleared from this INode instance.


containsID

public boolean containsID(java.lang.Object aId)
Indicates whether this INode instance contains the specified identifer as a child of this INode instance.
Parameters:
aId - the identifer of the child INode instance for which to search.
Returns:
true if this INode instance contains the specified child.

getList

public java.util.List getList(java.lang.Object aId)
Returns the List of INode child instances with the specified identifer. The list is in insertion order: the first INode child instance added to this INode instance is the first INode child instance in the returned List instance. Returns null if this INode instance does not contain any INode child instances with the specified identifier.

The returned List instance is immutable. That is, you cannot alter the position or size of the returned List instance.

Parameters:
aId - identifer whose associated INode child instances are returned.
Returns:
the List of INode child instances with the specified identifer, or null if this INode contains no children with the specified identifier.
See Also:
get(Object), get(int), remove(INode), add(INode)

get

public INode get(java.lang.Object aId)
Returns the first INode child instance that contains specified identifer. Returns null if this INode instance does not contain children with specified identifer.
Parameters:
aId - identifer whose associated INode child instances are returned.
Returns:
the first INode child instances with the specified identifer, or null if this INode instance contains no children for this identifer.
See Also:
get(int), remove(INode), add(INode)

get

public INode get(int aIndex)
Returns the INode child instance at the specified index. Indexes are 0 based.
Parameters:
aIndex - the index of the INode child instance to return.
Returns:
the INode child instance at the specified index.
Throws:
ArrayIndexOutOfBoundsException - if there is no value at the specified index. Said differently, this INode instance's size is less than the specified index.
See Also:
get(Object), remove(INode), add(INode)

remove

public void remove(INode aNode)
Removes the INode child instance for the specified identifer from this INode instance if present.

Fires an INodeResources.REMOVE_PROPERTY property change event.

Parameters:
aNode - INode child instance to be removed from this INode instance.
See Also:
get(Object), get(int), add(INode)

add

public void add(INode aNode)
Appends the specified INode child instance to the end of this INode instances child collection. This method automatically adds this INode instance as a parent of the specified child INode instance.

Fires an INodeResources.ADD_PROPERTY property change event.

Parameters:
aNode - INode child instance to be appended to this INode instance.
See Also:
add(INode, boolean), get(Object), get(int), remove(INode)

add

public void add(INode aNode,
                boolean bAddParent)
Appends the specified INode child instance to the end of this INode instance's child collection. Per the value of the boolean parameter, will add this INode instance as a parent of the specified child INode instance.

Fires an INodeResources.ADD_PROPERTY property change event.

Parameters:
aNode - INode child instance to be appended to this INode instance.
bAddParent - if true, will add this INode instance as the parent of the specified child INode instance, if false, does not add parent link to the child.
See Also:
add(INode), get(Object), get(int), remove(INode)

addParent

public void addParent(INode aParent)
Sets the parent INode instance for this INode instance.

This method is semantically dangerous to client developers. It could put the graph structure that this INode instance belongs to into an inconsistant state. Use this method with caution.

Fires an INodeResources.PARENT_PROPERTY property change event.

Parameters:
aParent - the INode parent instance to be set.
See Also:
removeParent(INode), getParents()

getParents

public java.util.Iterator getParents()
Returns an Iterator over the INode parent instances of this INode instance.
Returns:
the parent INode instances for this INode instance.
See Also:
removeParent(INode), addParent(INode)

removeParent

public void removeParent(INode aParent)
Removes the specified parent INode instance from this INode instance.
Parameters:
aParent - the Parent to remove from this INode instance.
See Also:
addParent(INode), getParents()

iterator

public java.util.Iterator iterator()
Returns an Iterator over this INode instance's children. This is a shallow operation, iterating through this INode instance's children and no further child generations. If you wish deep iterators, see the net.sourceforge.esw.graph.decorators package.
Returns:
an iterator over the INode child instances of this INode instance.

acceptVisitor

public void acceptVisitor(IGraphVisitor aVisitor)
Requests that this INode instance accept the specified IGraphVisitor instance and that visiting of this INode struture begin. This is a shallow operation, visiting this INode instance's children and no further child generations. If you wish deep visits, see the net.sourceforge.esw.graph.decorators package.
Parameters:
aVisitor - the IGraphVisitor instance to visit the children of this INode instance.


Copyright 2002 Free Software Foundation. All Rights Reserved.