|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
An "abstract" tree node relation in a tree (parent-child) data relationship. A parent may have none or more non-null children; and, a child may have none (orphan) or one parent. Supports both set and list types of children stores.
Uses the "mixed delegation" pattern, which allows parent and child delegators to use this tree node as a public delegate, but with navigation methods (accessors) handling delegators, not tree nodes. A side effect of mixed delegation, however, is that mutators handle tree nodes, not delegates.
This tree node does not require a "true" acyclic tree. If used to implement a true tree, note that cycle checking can be expensive. As such, true tree implementations must either check if a relation causes a cycle before any mutation (see TreeNodes.isAcyclic()), or they can perform easy checks and be tolerant of cycles, such as when tracing ancestors or descendants.
Method Summary | |
void |
addChild(int index,
TreeNode child)
Adds a child to this parent. |
void |
addChild(TreeNode child)
Adds a child to this parent. |
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. |
java.lang.Object |
getParent()
Gets the parent of this child relation. |
boolean |
hasChildren()
Returns true if this parent has any children, false if none. |
void |
implSetParent(TreeNode parent)
Used by the system to mutually set the parent of this child. |
void |
removeChild(TreeNode child)
Removes a child from this parent, and makes the child an orphan. |
Methods inherited from interface gumbo.util.relation.Relation |
canFindRelation, findRelation, getAddedConnectionOut, getRelationship, getRemovingConnectionOut, implReadConnections, implWriteConnections, setRelationship |
Methods inherited from interface gumbo.util.Disposable |
dispose, isDisposed |
Methods inherited from interface gumbo.util.Delegatable |
getDelegator, initDelegator, isDelegatorInited |
Method Detail |
public java.lang.Object getParent()
public void addChild(TreeNode child)
child
- 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.
java.lang.IllegalStateException
- The child already has a parent.public void addChild(int index, TreeNode child)
index
- List index (>=0, <=size). If <0, same as
addChild(Object) regardless of children store type.child
- Child relation. Never null. Unless otherwise noted,
duplicates are ignored. Note that a SetList children store
will throw an exception for duplicates.
java.lang.IllegalStateException
- The child already has a parent.
java.lang.UnsupportedOperationException
- The children store
is not a list.public void removeChild(TreeNode child)
child
- Child relation. Never null. Unless otherwise noted,
a missing child is ignored.public boolean hasChildren()
public Group getChildren()
public TreeNode findTreeNode(java.lang.Object delegator)
delegator
- The delegator. Never null.
java.lang.IllegalArgumentException
- Delegator is null.
java.lang.IllegalStateException
- This relation is not in a
relationship.public void implSetParent(TreeNode parent)
parent
- Parent relation. Null if none (orphan).
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |