2.17.2: 2011-06-17

net.sf.basedb.util
Class Tree<E>

java.lang.Object
  extended by net.sf.basedb.util.Tree<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>

public class Tree<E>
extends Object
implements Collection<E>

Version:
2.0
Author:
Nicklas
Last modified
$Date: 2010-01-18 08:31:09 +0100 (Mon, 18 Jan 2010) $

Nested Class Summary
private  class Tree.ElementIterator
          An iterator that return elements for each node.
static class Tree.Entry<E>
          Represents an entry for a node in the tree.
private  class Tree.EntryIterator
          An iterator that return entries for each node.
 
Field Summary
private  Map<E,Tree.Entry<E>> entries
           
private  E root
           
 
Constructor Summary
Tree(E root)
          Create a new tree with the with the default initial capacity (16).
Tree(E root, int initialCapacity)
          Create a new tree with the with the specified initial capacity.
 
Method Summary
 boolean add(E o)
          Not supported.
 boolean addAll(Collection<? extends E> c)
          Not supported.
private  void addEntry(Tree.Entry<E> entry)
           
 void clear()
          Clear all elements except the root element.
 boolean contains(Object o)
           
 boolean containsAll(Collection<?> c)
           
 Iterator<Tree.Entry<E>> entryIterator()
          Create an iterator for the tree that returns entry object.
 Iterator<Tree.Entry<E>> entryIterator(E node)
          Create an iterator for the tree starting at a specific node.
 boolean equals(Object o)
          Equality only tests if the object is the same instance of this tree.
 Tree.Entry<E> getEntry(E node)
          Get the entry for an arbitrary node.
 Tree.Entry<E> getRootEntry()
          Get the entry for the root node.
 boolean isEmpty()
           
 Iterator<E> iterator()
           
 boolean remove(Object o)
          Not supported.
 boolean removeAll(Collection<?> c)
          Not supported.
 boolean retainAll(Collection<?> c)
          Not supported.
 int size()
           
 Object[] toArray()
          Not supported.
<T> T[]
toArray(T[] a)
          Not supported.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Collection
hashCode
 

Field Detail

root

private final E root

entries

private final Map<E,Tree.Entry<E>> entries
Constructor Detail

Tree

public Tree(E root)
Create a new tree with the with the default initial capacity (16).

Parameters:
root - The root node element of the tree

Tree

public Tree(E root,
            int initialCapacity)
Create a new tree with the with the specified initial capacity.

Parameters:
root - The root node element of the tree
initialCapacity - The initial capacity
Method Detail

add

public boolean add(E o)
Not supported.

Specified by:
add in interface Collection<E>
Throws:
UnsupportedOperationException - Always
See Also:
Tree.Entry.addChild(Object)

addAll

public boolean addAll(Collection<? extends E> c)
Not supported.

Specified by:
addAll in interface Collection<E>
Throws:
UnsupportedOperationException - Always

clear

public void clear()
Clear all elements except the root element.

Specified by:
clear in interface Collection<E>

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection<E>

containsAll

public boolean containsAll(Collection<?> c)
Specified by:
containsAll in interface Collection<E>

equals

public boolean equals(Object o)
Equality only tests if the object is the same instance of this tree. Note! In the future, the implementation may change to also check the entire tree structure.

Specified by:
equals in interface Collection<E>
Overrides:
equals in class Object

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection<E>

iterator

public Iterator<E> iterator()
Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>

remove

public boolean remove(Object o)
Not supported.

Specified by:
remove in interface Collection<E>
Throws:
UnsupportedOperationException - Always

removeAll

public boolean removeAll(Collection<?> c)
Not supported.

Specified by:
removeAll in interface Collection<E>
Throws:
UnsupportedOperationException - Always

retainAll

public boolean retainAll(Collection<?> c)
Not supported.

Specified by:
retainAll in interface Collection<E>
Throws:
UnsupportedOperationException - Always

size

public int size()
Specified by:
size in interface Collection<E>

toArray

public Object[] toArray()
Not supported.

Specified by:
toArray in interface Collection<E>
Throws:
UnsupportedOperationException - Always

toArray

public <T> T[] toArray(T[] a)
Not supported.

Specified by:
toArray in interface Collection<E>
Throws:
UnsupportedOperationException - Always

getRootEntry

public Tree.Entry<E> getRootEntry()
Get the entry for the root node.

Returns:
The Entry object for the root node.

getEntry

public Tree.Entry<E> getEntry(E node)
Get the entry for an arbitrary node.

Parameters:
node - The node to get the entry for.
Returns:
An Entry object or null if the node isn't found

entryIterator

public Iterator<Tree.Entry<E>> entryIterator()
Create an iterator for the tree that returns entry object. The iterator starts at the root.

Returns:
An Iterator object
See Also:
iterator()

entryIterator

public Iterator<Tree.Entry<E>> entryIterator(E node)
Create an iterator for the tree starting at a specific node.

Parameters:
node - The node to start at
Returns:
An Iterator object
See Also:
iterator()

addEntry

private void addEntry(Tree.Entry<E> entry)

2.17.2: 2011-06-17