org.vizzini.util.tree
Class AbstractTreeNodeCollection

java.lang.Object
  extended by org.vizzini.util.tree.AbstractTreeNodeCollection
All Implemented Interfaces:
Cloneable, ITreeNodeCollection
Direct Known Subclasses:
DefaultTreeNodeCollection

public abstract class AbstractTreeNodeCollection
extends Object
implements ITreeNodeCollection

Provides base functionality for a tree node collection.

Since:
v0.3
Version:
v0.3
Author:
Jeffrey M. Thompson

Constructor Summary
AbstractTreeNodeCollection()
           
 
Method Summary
 void add(int index, ITreeNode child)
          Add the given child at the given index.
 boolean add(ITreeNode child)
          Add the given child.
 boolean addAll(ITreeNodeCollection collection)
          Add the given collection to this.
 void clear()
          Clear the children.
 Object clone()
          Return a clone of this instance.
 boolean contains(ITreeNode treeNode)
          Return true if this contains the given node.
protected  List deepClone(List list)
          Create a new List which contains clones of the items in the given list.
 boolean equals(Object object)
          Return true if the given object is equal to this.
 ITreeNode get(int index)
          Return the child at the given index.
 List getNodes()
           
 int hashCode()
          Returns a hash code value for the object.
 int indexOf(ITreeNode treeNode)
          Return the index of the given node.
 boolean isEmpty()
          Return true if this is empty.
 Iterator iterator()
          Return an iterator over this collection.
 ITreeNode remove(int index)
          Remove the object at the given index.
 boolean remove(ITreeNode child)
          Remove the given child.
 ITreeNode set(int index, ITreeNode child)
          Set the given object at the given index.
 void setNodes(List nodes)
           
 int size()
          Return the size of this collection.
 ITreeNode[] toArray()
          Return an array representation of this collection.
 ITreeNode[] toArray(ITreeNode[] nodes)
          Return an array representation of this collection.
 String toString()
          Return a string representation of this object.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractTreeNodeCollection

public AbstractTreeNodeCollection()
Method Detail

add

public boolean add(ITreeNode child)
Add the given child.

Specified by:
add in interface ITreeNodeCollection
Since:
v0.3

add

public void add(int index,
                ITreeNode child)
Add the given child at the given index.

Specified by:
add in interface ITreeNodeCollection
Since:
v0.3

addAll

public boolean addAll(ITreeNodeCollection collection)
Add the given collection to this.

Specified by:
addAll in interface ITreeNodeCollection
Since:
v0.3

clear

public void clear()
Clear the children.

Specified by:
clear in interface ITreeNodeCollection
Since:
v0.3

clone

public Object clone()
Return a clone of this instance.

Specified by:
clone in interface ITreeNodeCollection
Overrides:
clone in class Object
Since:
v0.3

contains

public boolean contains(ITreeNode treeNode)
Return true if this contains the given node.

Specified by:
contains in interface ITreeNodeCollection
Since:
v0.3

equals

public boolean equals(Object object)
Return true if the given object is equal to this.

Overrides:
equals in class Object
Parameters:
object - The object to compare.
Since:
v0.3

get

public ITreeNode get(int index)
Return the child at the given index.

Specified by:
get in interface ITreeNodeCollection
Since:
v0.3

getNodes

public List getNodes()
Returns:
Return nodes.
Since:
v0.3

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class Object
Since:
v0.3

indexOf

public int indexOf(ITreeNode treeNode)
Return the index of the given node.

Specified by:
indexOf in interface ITreeNodeCollection
Since:
v0.3

isEmpty

public boolean isEmpty()
Return true if this is empty.

Specified by:
isEmpty in interface ITreeNodeCollection
Since:
v0.3

iterator

public Iterator iterator()
Return an iterator over this collection.

Specified by:
iterator in interface ITreeNodeCollection
Since:
v0.3

remove

public boolean remove(ITreeNode child)
Remove the given child.

Specified by:
remove in interface ITreeNodeCollection
Since:
v0.3

remove

public ITreeNode remove(int index)
Remove the object at the given index.

Specified by:
remove in interface ITreeNodeCollection
Since:
v0.3

set

public ITreeNode set(int index,
                     ITreeNode child)
Set the given object at the given index.

Specified by:
set in interface ITreeNodeCollection
Parameters:
index - Index.
child - Child to set.
Returns:
the element previously at the specified position.
Since:
v0.3

setNodes

public void setNodes(List nodes)
Parameters:
nodes - the nodes to set
Since:
v0.3

size

public int size()
Return the size of this collection.

Specified by:
size in interface ITreeNodeCollection
Since:
v0.3

toArray

public ITreeNode[] toArray()
Return an array representation of this collection.

Specified by:
toArray in interface ITreeNodeCollection
Since:
v0.3

toArray

public ITreeNode[] toArray(ITreeNode[] nodes)
Return an array representation of this collection.

Specified by:
toArray in interface ITreeNodeCollection
Since:
v0.3

toString

public String toString()
Return a string representation of this object.

Overrides:
toString in class Object
Since:
v0.3

deepClone

protected List deepClone(List list)
Create a new List which contains clones of the items in the given list.

Parameters:
list - List to clone.
Since:
v0.3


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02