|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.springsource.util.common.ThreadSafeArrayListTree<V>
V
- type of values in treepublic final class ThreadSafeArrayListTree<V>
ThreadSafeArrayListTree
is a value with an ordered collection of subtrees of the same type as the main tree.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.springsource.util.common.Tree |
---|
Tree.ExceptionThrowingTreeVisitor<V,E extends java.lang.Exception>, Tree.TreeVisitor<V> |
Field Summary | |
---|---|
private java.util.List<ThreadSafeArrayListTree<V>> |
children
|
private java.lang.Object |
monitor
|
private Tree<V> |
parent
|
private static java.lang.Object |
tieMonitor
|
private V |
value
|
Constructor Summary | |
---|---|
protected |
ThreadSafeArrayListTree(Tree<V> tree,
Tree<V> parent,
java.lang.Object monitor)
Construct a tree by deeply copying the given tree, using the given parent, and inheriting the given monitor. |
|
ThreadSafeArrayListTree(V value)
Construct a tree with the given value, which may be null . |
protected |
ThreadSafeArrayListTree(V value,
java.lang.Object monitor)
|
Method Summary | ||
---|---|---|
Tree<V> |
addChild(Tree<V> child)
Adds a new child tree to this node's children. |
|
boolean |
equals(java.lang.Object obj)
|
|
private ThreadSafeArrayListTree<V> |
getChild(int i)
|
|
java.util.List<Tree<V>> |
getChildren()
Returns a list of this tree's children (not copies of the children). |
|
Tree<V> |
getParent()
Returns this tree's parent. |
|
V |
getValue()
Returns the tree's value. |
|
int |
hashCode()
|
|
private int |
numChildren()
|
|
boolean |
removeChild(Tree<V> child)
Removes the first occurrence of the given child tree from this node's children. |
|
private void |
setParent(Tree<V> child,
Tree<V> parent)
|
|
int |
size()
Returns the number of nodes in the tree. |
|
java.lang.String |
toString()
|
|
|
visit(Tree.ExceptionThrowingTreeVisitor<V,E> visitor)
Traverse this Tree in preorder (see below) and call the visit method of the given
Tree.ExceptionThrowingTreeVisitor at each node. |
|
void |
visit(Tree.TreeVisitor<V> visitor)
Traverse this ThreadSafeArrayListTree in preorder (see below) and call the visit method of the given
Tree.TreeVisitor at each node. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private volatile V value
private final java.lang.Object monitor
private static final java.lang.Object tieMonitor
private final java.util.List<ThreadSafeArrayListTree<V>> children
private Tree<V> parent
Constructor Detail |
---|
public ThreadSafeArrayListTree(V value)
null
.
value
- the value of the tree, which may be null
protected ThreadSafeArrayListTree(V value, java.lang.Object monitor)
protected ThreadSafeArrayListTree(Tree<V> tree, Tree<V> parent, java.lang.Object monitor)
tree
- the tree to copyparent
- the parent of the new tree or null
monitor
- the monitor to inheritMethod Detail |
---|
public final V getValue()
null
.
getValue
in interface Tree<V>
null
public java.util.List<Tree<V>> getChildren()
null
.
The returned list is synchronized to preserve thread safety, but may still result in
ConcurrentModificationException being thrown.
getChildren
in interface Tree<V>
public Tree<V> addChild(Tree<V> child)
addChild
in interface Tree<V>
child
- the child tree to add
public boolean removeChild(Tree<V> child)
true
if the
child was found and removed, otherwise false
.
removeChild
in interface Tree<V>
child
- the child tree to remove
true
if the child tree was removed successfully, otherwise false
.List.remove(java.lang.Object)
private void setParent(Tree<V> child, Tree<V> parent)
public void visit(Tree.TreeVisitor<V> visitor)
ThreadSafeArrayListTree
in preorder (see below) and call the visit method of the given
Tree.TreeVisitor
at each node. The visitor determines whether the children of each visited tree should
also be visited.
Preorder traversal visits the tree and then visits, in preorder, each child of the tree.
visit
in interface Tree<V>
visitor
- a Tree.TreeVisitor
public <E extends java.lang.Exception> void visit(Tree.ExceptionThrowingTreeVisitor<V,E> visitor) throws E extends java.lang.Exception
Tree
in preorder (see below) and call the visit method of the given
Tree.ExceptionThrowingTreeVisitor
at each node. The visitor determines whether the children of each visited
tree should also be visited.
Preorder traversal visits the tree and then visits, in preorder, each child of the tree.
visit
in interface Tree<V>
E
- type of exception possibly thrownvisitor
- the tree's visitor
E
- if an error occurs when visiting the tree
E extends java.lang.Exception
private ThreadSafeArrayListTree<V> getChild(int i)
private int numChildren()
public int size()
size
in interface Tree<V>
null
nodes in the treepublic int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public Tree<V> getParent()
null
.
getParent
in interface Tree<V>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |