|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gumbo.util.AbstractDisposable | +--gumbo.util.AbstractDelegatable | +--gumbo.util.AbstractDelegatable.Serial | +--gumbo.util.relation.AbstractRelation | +--gumbo.util.relation.AbstractTreeNode
A full implementation of the IntersectionTreeNode interface (see also AbstractTreeNodeDelegator).
To extend this class, implementors typically only need to override checkAddChild() and checkRemoveChild(). If overridden, the super method should be chained last to assure that the relation constract is satisfied. If mutators are overridden without superclass chaining be sure to check if this object is disposed, and to call checkAddChild() and checkRemoveChild(), as appropriate. Also, be sure the mutation is mutual (child added to parent, parent set in child).
The default implementation does not implement tree cycle checking, which is expensive, but does make checks for self-parent and self-child. If desired, use TreeNodes.isTreeValid() before creating a relationship to assure the new tree is acyclic.
Nested Class Summary | |
static class |
AbstractTreeNode.Auto
An AbstractTreeNode that automatically sets the relationship of relations (parent or child) when a connection is created, with the dead relation taking on the relationship of the live one. |
static class |
AbstractTreeNode.Global
An AbstractTreeNode.Auto that uses a singleton (global) relationship, and throws an exception if the relationship is changed. |
Nested classes inherited from class gumbo.util.AbstractDelegatable |
|
Constructor Summary | |
AbstractTreeNode(Relationship relationship)
Creates an instance with an uninitialized delegator. |
Method Summary | |
void |
addChild(int index,
TreeNode childR)
Ignores null and duplicate unless constrained by checkAddChild(), or the children store. |
void |
addChild(TreeNode childR)
Forwards to addChild(int, IntersectionTreeNode) |
protected void |
checkAddChild(TreeNode childR)
Called by the system before adding a child to this parent. |
protected void |
checkChild(java.lang.Object child)
Called by the system to check a child involved in a connection to this relation. |
protected void |
checkParent(java.lang.Object parent)
Called by the system to check a parent involved in a connection to this relation. |
protected void |
checkRemoveChild(TreeNode childR)
Called by the system before removing a child from this parent. |
protected void |
checkSetParent(TreeNode parentR)
Called by the system before setting the parent of this child. |
TreeNode |
findTreeNode(java.lang.Object delegator)
Convenience method for getting the tree node corresponding to a delegator in this tree node's relationship. |
Group |
getChildren()
Gets an immutable view of this parent's children. |
protected Group |
getChildrenGroup()
Gets the mutable children group. |
java.lang.Object |
getParent()
Gets the parent of this child relation. |
TreeNode |
getTreeNode()
Gets an immutable view of this tree node. |
boolean |
hasChildren()
Returns true if this parent has any children, false if none. |
protected void |
implDispose()
Disconnects this tree node from its parent and children. |
void |
implReadConnections(java.io.ObjectInputStream s)
Called by the system during deserialization when this relation should read its connection references from the serial input stream. |
void |
implSetParent(TreeNode parentR)
Ignores null unless constrained by checkSetParent(). |
void |
implWriteConnections(java.io.ObjectOutputStream s)
Called by the system during serialization when this relation should write its connection references to the serial output stream. |
protected java.util.Collection |
newChildrenStore()
Called by the system when it needs to lazily build the child store. |
void |
removeChild(TreeNode childR)
Ignores null and missing unless constrained by checkRemoveChild(). |
java.lang.String |
toString()
|
Methods inherited from class gumbo.util.relation.AbstractRelation |
canFindRelation, checkClearedRelationship, checkRelation, checkSettingRelationship, findRelation, getAddedConnectionOut, getRelationship, getRemovingConnectionOut, initedDelegator, setRelationship |
Methods inherited from class gumbo.util.AbstractDelegatable |
getDelegator, initDelegator, initingDelegator, isDelegatorInited |
Methods inherited from class gumbo.util.AbstractDisposable |
dispose, isDisposed |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface gumbo.util.relation.Relation |
canFindRelation, findRelation, getAddedConnectionOut, getRelationship, getRemovingConnectionOut, setRelationship |
Methods inherited from interface gumbo.util.Disposable |
dispose, isDisposed |
Methods inherited from interface gumbo.util.Delegatable |
getDelegator, initDelegator, isDelegatorInited |
Constructor Detail |
public AbstractTreeNode(Relationship relationship)
new AbstractTreeNode(r).initDelegator(d)
.
relationship
- This relation's relationship. Null if none
(a dead relation).Method Detail |
public TreeNode getTreeNode()
protected java.util.Collection newChildrenStore()
protected final Group getChildrenGroup()
protected void checkParent(java.lang.Object parent)
parent
- Parent delegator. Possibly null.protected void checkSetParent(TreeNode parentR)
parentR
- New parent relation. Null if none (orphan).protected void checkChild(java.lang.Object child)
child
- Child delegator. Possibly null.protected void checkAddChild(TreeNode childR)
childR
- Child relation. Possibly null or duplicate.protected void checkRemoveChild(TreeNode childR)
childR
- Child relation. Possibly null or missing.public java.lang.Object getParent()
TreeNode
getParent
in interface TreeNode
public void addChild(TreeNode childR)
addChild
in interface TreeNode
childR
- Child relation. Never null. Unless otherwise noted,
duplicates are the same as a new child. Note that a SetList children
store will throw an exception for duplicates.public void addChild(int index, TreeNode childR)
addChild
in interface TreeNode
index
- List index (>=0, <=size). If <0, same as
addChild(Object) regardless of children store type.childR
- Child relation. Never null. Unless otherwise noted,
duplicates are ignored. Note that a SetList children store
will throw an exception for duplicates.public void removeChild(TreeNode childR)
removeChild
in interface TreeNode
childR
- Child relation. Never null. Unless otherwise noted,
a missing child is ignored.public boolean hasChildren()
TreeNode
hasChildren
in interface TreeNode
public Group getChildren()
TreeNode
getChildren
in interface TreeNode
public TreeNode findTreeNode(java.lang.Object delegator)
TreeNode
findTreeNode
in interface TreeNode
delegator
- The delegator. Never null.
public void implSetParent(TreeNode parentR)
implSetParent
in interface TreeNode
parentR
- Parent relation. Null if none (orphan).public void implWriteConnections(java.io.ObjectOutputStream s) throws java.io.IOException, java.lang.ClassNotFoundException
Relation
implWriteConnections
in interface Relation
s
- Output stream. Never null.
java.io.IOException
java.lang.ClassNotFoundException
public void implReadConnections(java.io.ObjectInputStream s) throws java.io.IOException, java.lang.ClassNotFoundException
Relation
implReadConnections
in interface Relation
s
- Output stream. Never null.
java.io.IOException
java.lang.ClassNotFoundException
protected void implDispose()
implDispose
in class AbstractRelation
public java.lang.String toString()
toString
in class AbstractRelation
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |