com.acsinet_solutions.util.adt
Class ITreeNode

java.lang.Object
  extended by com.acsinet_solutions.util.adt.ITreeNode
All Implemented Interfaces:
java.io.Serializable

public class ITreeNode
extends java.lang.Object
implements java.io.Serializable

A tree node simple structure, used in build utilities.

WARNING! This implementation is not thread safe

Author:
Santiago Arriaga
See Also:
Serialized Form

Constructor Summary
ITreeNode(java.lang.Object obj)
           
 
Method Summary
 int addSon(java.lang.String name, ITreeNode son)
          Add a son to the current tree
 java.lang.String getName()
          Get the name under which the current node exists
 java.lang.Object getObject()
          Return the internal object hold by this node
 ITreeNode getParent()
          Get the current parent, if any
 int getPosition()
          Get the position of the current node in the sibling list
 ITreeNode getRoot()
          Get the root node
 java.util.List<ITreeNode> getSiblings()
          Get the sibling list
 ITreeNode getSon(java.lang.String name, int pos)
          Get the son at a given position.
 java.util.Collection<java.lang.String> getSonNames()
          Get a List of the names in this ITreeNode
 java.util.List<ITreeNode> getSons(java.lang.String name)
          Get the son values
 void removeSon(ITreeNode son)
          Remove a son from the current tree
 java.util.Iterator<ITreeNode> sonIterator()
          get the complete son iterator for this TreeNode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ITreeNode

public ITreeNode(java.lang.Object obj)
Parameters:
obj - THe maybe-null Object that this node holds
Method Detail

getObject

public final java.lang.Object getObject()
Return the internal object hold by this node


getParent

public final ITreeNode getParent()
Get the current parent, if any


getName

public final java.lang.String getName()
Get the name under which the current node exists

Returns:
A not-null not-empty String if the node has a parent; null if the node is a root node

getRoot

public final ITreeNode getRoot()
Get the root node

Returns:
A not-null ITreeNode instance

addSon

public final int addSon(java.lang.String name,
                        ITreeNode son)
Add a son to the current tree

Parameters:
name - A not-null name where the son will be added
son - The not-null ITreeNode to be added

removeSon

public final void removeSon(ITreeNode son)
Remove a son from the current tree

Parameters:
son - A not-null ITreeNode son of the curren instance

getSons

public final java.util.List<ITreeNode> getSons(java.lang.String name)
Get the son values

Returns:
A not-null immutable List of ITreeNode instances

getSon

public final ITreeNode getSon(java.lang.String name,
                              int pos)
Get the son at a given position.

Returns:
A not-null ITreeNode instance

getSonNames

public final java.util.Collection<java.lang.String> getSonNames()
Get a List of the names in this ITreeNode

Returns:
A not-null not-empty Immutable List of not-null not-empty String instances

getSiblings

public final java.util.List<ITreeNode> getSiblings()
Get the sibling list

Returns:
A not-null immutable List instance

getPosition

public final int getPosition()
Get the position of the current node in the sibling list


sonIterator

public final java.util.Iterator<ITreeNode> sonIterator()
get the complete son iterator for this TreeNode