|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--net.sourceforge.esw.util.SupportObject
|
+--net.sourceforge.esw.graph.Node
Provides a universal, graph based, generic data structure.
This is the default implementation of the INode interface
within the ESW framework.
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();
IGraphVisitor,
ISupportObject,
NodeFactory,
Object.equals(java.lang.Object),
Object.hashCode(), Serialized Form| Field Summary | |
protected java.util.List |
list
The List instance containing this INode
instance's children, in insertion order. |
protected java.util.Map |
map
The Map instance containing this INode instance's
children. |
protected java.util.List |
parents
The List instancecontaining this INode instance's
parents, in insertion order. |
protected java.lang.Object |
value
The value of this INode instance. |
| Fields inherited from class net.sourceforge.esw.util.SupportObject |
id, properties, propertyChildren, propertyListeners, vetoableChildren, vetoableListeners |
| Constructor Summary | |
protected |
Node()
Creates a new Node instance. |
| 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. |
java.lang.Object |
clone()
Creates and returns a shallow copy of 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. |
boolean |
equals(java.lang.Object aObject)
Checks for equality between this INode instance and the
specified Object. |
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 |
int |
hashCode()
Returns a hash code value for this INode instance. |
protected int |
hashCodeForNode(INode aNode)
Returns the shallow hashCode for this specified 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. |
protected boolean |
nodesEqual(INode aNodeA,
INode aNodeB)
Checks for equality between the two specified INode instances. |
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. |
java.lang.String |
toString()
Returns a String representation of this INode
instance. |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| 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 |
| Field Detail |
protected java.lang.Object value
INode instance.protected java.util.Map map
Map instance containing this INode instance's
children. Used for fast access by identifier.protected java.util.List list
List instance containing this INode
instance's children, in insertion order. Used for fast access by position.protected java.util.List parents
List instancecontaining this INode instance's
parents, in insertion order. Used for fast access by position.| Constructor Detail |
protected Node()
Node instance.
This method is proected to force creation to be performed by the
NodeFactory. See Section 6.6.1 of the Java Language
Specification for an explanation of why this method cannot be invoked by
classes outside this package.
| Method Detail |
public java.lang.Object getValue()
INode instancegetValue in interface INodeINode instance.setValue(Object)public void setValue(java.lang.Object aValue)
INode instance.
Fires an INodeResources.VALUE_PROPERTY property change event.
setValue in interface INodeaValue - the value for this INode instance.getValue()public int size()
INode instance. If the
INode contains more than Integer.MAX_VALUE
elements, returns Integer.MAX_VALUE.size in interface INodeINode instance.isEmpty()public boolean isEmpty()
INode instance has no children.isEmpty in interface INodetrue if this INode instance contains no
children.size()public void clear()
INode instance.
Fires an INodeResources.CLEAR_PROPERTY property change event
only if there were children that were cleared from this INode
instance.
clear in interface INodepublic boolean containsID(java.lang.Object aId)
INode instance contains the
specified identifer as a child of this INode instance.containsID in interface INodeaId - the identifer of the child INode instance for which
to search.true if this INode instance contains the
specified child.public java.util.List getList(java.lang.Object aId)
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.
getList in interface INodeaId - identifer whose associated INode child instances
are returned.List of INode child instances with
the specified identifer, or null if this
INode contains no children with the specified
identifier.get(Object),
get(int),
remove(INode),
add(INode)public INode get(java.lang.Object aId)
INode child instance that contains specified
identifer. Returns null if this INode instance
does not contain children with specified identifer.get in interface INodeaId - identifer whose associated INode child instances
are returned.INode child instances with the specified
identifer, or null if this INode
instance contains no children for this identifer.get(int),
remove(INode),
add(INode)public INode get(int aIndex)
INode child instance at the specified index.
Indexes are 0 based.get in interface INodeaIndex - the index of the INode child instance to return.INode child instance at the specified index.ArrayIndexOutOfBoundsException - if there is no value at the
specified index. Said differently,
this INode instance's
size is less than the specified
index.get(Object),
remove(INode),
add(INode)public void remove(INode aNode)
INode child instance for the specified identifer
from this INode instance if present.
Fires an INodeResources.REMOVE_PROPERTY property change event.
remove in interface INodeaNode - INode child instance to be removed from this
INode instance.get(Object),
get(int),
add(INode)public void add(INode aNode)
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.
add in interface INodeaNode - INode child instance to be appended to this
INode instance.add(INode, boolean),
get(Object),
get(int),
remove(INode)
public void add(INode aNode,
boolean bAddParent)
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.
add in interface INodeaNode - 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.add(INode),
get(Object),
get(int),
remove(INode)public void addParent(INode aParent)
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.
addParent in interface INodeaParent - the INode parent instance to be set.removeParent(INode),
getParents()public java.util.Iterator getParents()
Iterator over the INode parent
instances of this INode instance.getParents in interface INodeINode instances for this INode
instance.removeParent(INode),
addParent(INode)public void removeParent(INode aParent)
INode instance from this
INode instance.removeParent in interface INodeaParent - the Parent to remove from this INode instance.addParent(INode),
getParents()public java.util.Iterator iterator()
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.iterator in interface INodeINode child instances of this
INode instance.public void acceptVisitor(IGraphVisitor aVisitor)
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.acceptVisitor in interface INodeaVisitor - the IGraphVisitor instance to visit the
children of this INode instance.public java.lang.String toString()
String representation of this INode
instance.toString in class java.lang.ObjectString representation of this INode
instance.public boolean equals(java.lang.Object aObject)
INode instance and the
specified Object.
The specified object must be an INode instance and be non-null.
equals in class java.lang.ObjectaObject - the object for which to check equality.INode instance are equal.public int hashCode()
INode instance.hashCode in class java.lang.Objectpublic java.lang.Object clone()
INode instance.clone in interface ICloneableclone in class java.lang.ObjectINode instance.protected int hashCodeForNode(INode aNode)
INode
instance.
aNode - the INode instance on which to check shallow
hashCode.
protected boolean nodesEqual(INode aNodeA,
INode aNodeB)
INode instances.
aNodeA - the first INode instance to check for equality.aNodeB - the second INode instance to check for equality.INode instances are equal.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||