|
qflib 0.98.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
With the help of this interface the methods of the TreeUtil
class can be applied to every kind of tree structure without
the need to change anything in the implementation of the structure itself
(provided that the basic tree functionality is there).
A TreeAdapter can also be used to get different structural views of the same tree hierachy. An Example would be a DOM TreeAdapter that hides all non-Element nodes.
Method Summary | |
int |
getChildCount(java.lang.Object parent)
Get the number of children of a node. |
java.lang.Object |
getChildNode(java.lang.Object parent,
int index)
Get a child of a node. |
java.util.Enumeration |
getChildren(java.lang.Object parent)
Get an Enumeration for the children of a node. |
java.lang.Object |
getFirstChildNode(java.lang.Object parent)
Get the first child of a node. |
int |
getIndexOfChildNode(java.lang.Object parent,
java.lang.Object child)
Get the index of a child in a node's list of children. |
java.lang.Object |
getLastChildNode(java.lang.Object parent)
Get the last child of a node. |
java.lang.Object |
getNextSibling(java.lang.Object node)
Get the next sibling of a node. |
java.lang.Object |
getParentNode(java.lang.Object child)
Get the parent of a node. |
java.lang.Object |
getPreviousSibling(java.lang.Object node)
Get the previous sibling of a node. |
boolean |
isEnumerationBased()
Query whether the TreeAdapter implementation supports enumeration based child access efficiently. |
boolean |
isIndexBased()
Query whether the TreeAdapter implementation supports index based child access efficiently. |
boolean |
isLeaf(java.lang.Object node)
Query whether a node is a leaf. |
boolean |
isLinkBased()
Query whether the TreeAdapter implementation supports link based child access efficiently. |
Method Detail |
public java.lang.Object getParentNode(java.lang.Object child)
child
- The node to query for the parent.public boolean isLeaf(java.lang.Object node)
node
- The node to query.public boolean isIndexBased()
If the list of children of a node is implemented as a linked list for
example, index based access is very inefficient, while an array based
implementation should retrun true. The index based methods getChildCount
, getChildNode
and
getIndexOfChildNode
have to be implemented
in any case.
public int getChildCount(java.lang.Object parent)
parent
- The node to query.public java.lang.Object getChildNode(java.lang.Object parent, int index) throws java.lang.IndexOutOfBoundsException
parent
- The node to query.index
- The index of the child.java.lang.IndexOutOfBoundsException
- If the index is invalid.public int getIndexOfChildNode(java.lang.Object parent, java.lang.Object child)
parent
- The node to query.child
- The child to look for.public boolean isLinkBased()
If the list of children of a node is implemented as a linked list for
example, link based access is very efficient, while an array based
implementation should retrun false. The link based methods getFirstChildNode
, getLastChildNode
, getNextSibling
and getPreviousSibling
have to be implemented in any
case.
public java.lang.Object getFirstChildNode(java.lang.Object parent)
parent
- The node whose child to get.public java.lang.Object getLastChildNode(java.lang.Object parent)
parent
- The node whose child to get.public java.lang.Object getPreviousSibling(java.lang.Object node)
node
- The node whose sibling to get.public java.lang.Object getNextSibling(java.lang.Object node)
node
- The node whose sibling to get.public boolean isEnumerationBased()
This method should return true only if Enumeration based child access if more efficient than index or linked based access.
public java.util.Enumeration getChildren(java.lang.Object parent)
isEnumerationBased
returns true.parent
- The node whose children to get.
|
qflib 0.98.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |