de.init.its.process.support
Class ItsTree<T extends Element>

java.lang.Object
  extended by de.init.its.process.support.ItsTree<T>
Type Parameters:
T -

public class ItsTree<T extends Element>
extends java.lang.Object

tree data structure implementation

Author:
m.kandora

Field Summary
protected  java.util.List<ItsTree<T>> children
           
protected static java.lang.String EOL
           
protected  T head
           
protected  java.util.Map<T,ItsTree<T>> mapping
           
protected  ItsTree<T> next
           
protected  ItsTree<T> parent
           
 
Constructor Summary
ItsTree(T head)
          Creates a new Tree with an head element
 
Method Summary
 java.util.Deque<ItsTree<T>> findAllByName(java.lang.String prefix, java.lang.String name)
          Returns a list of all Elements specified by name an prefix.
 ItsTree<T> findByName(java.lang.String prefix, java.lang.String name)
          Returns the first Element, that is matched by prefix and the name
 java.util.List<ItsTree<T>> getChildren()
          Returns the children of this node
 T getHead()
          Returns the head of this node
 ItsTree<T> getParent()
          Returns the parent of this node
 java.util.Collection<T> getSuccessors()
          returns the successive elements of this node
 java.util.Collection<T> getSuccessors(T root)
          returns the successors ofthe root element
 boolean hasChildren()
          Returns true, if this subtree contains children
 boolean hasNextSibling()
          Returns true, if it has a next sibling
 ItsTree<T> insert(ItsTree<T> tree)
          Inserts a subtree as a child to this node
 ItsTree<T> insert(T node)
          Inserts an element as child to this tree and returns the child subtree
 ItsTree<T> insert(T parent, T node)
          Inserts an element as child for the parent and returns the child subtree
 boolean isEmpty()
          Returns true, if the head of this tree is empty (eg. null)
 ItsTree<T> nextSibling()
          Returns the next sibling
 java.lang.String print()
          prints the tree with an intendation level
 ItsTree<T> remove(T node)
          Removes a node form the tree and returns the subtree
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

protected ItsTree<T extends Element> parent

next

protected ItsTree<T extends Element> next

head

protected T extends Element head

children

protected java.util.List<ItsTree<T extends Element>> children

mapping

protected java.util.Map<T extends Element,ItsTree<T extends Element>> mapping

EOL

protected static final java.lang.String EOL
Constructor Detail

ItsTree

public ItsTree(T head)
Creates a new Tree with an head element

Parameters:
head -
Method Detail

insert

public ItsTree<T> insert(T parent,
                         T node)
Inserts an element as child for the parent and returns the child subtree

Parameters:
parent -
node -
Returns:

insert

public ItsTree<T> insert(T node)
Inserts an element as child to this tree and returns the child subtree

Parameters:
node -
Returns:

insert

public ItsTree<T> insert(ItsTree<T> tree)
Inserts a subtree as a child to this node

Parameters:
tree - the tree to insert at this node
Returns:
the inserted tree (is equal to the parameter, useful for method chaining)

remove

public ItsTree<T> remove(T node)
Removes a node form the tree and returns the subtree

Parameters:
node -
Returns:

getHead

public T getHead()
Returns the head of this node

Returns:

getParent

public ItsTree<T> getParent()
Returns the parent of this node

Returns:

getChildren

public java.util.List<ItsTree<T>> getChildren()
Returns the children of this node

Returns:

hasChildren

public boolean hasChildren()
Returns true, if this subtree contains children

Returns:

getSuccessors

public java.util.Collection<T> getSuccessors()
returns the successive elements of this node

Returns:

getSuccessors

public java.util.Collection<T> getSuccessors(T root)
returns the successors ofthe root element

Parameters:
root -
Returns:

isEmpty

public boolean isEmpty()
Returns true, if the head of this tree is empty (eg. null)

Returns:
true, if head is null

findAllByName

public java.util.Deque<ItsTree<T>> findAllByName(java.lang.String prefix,
                                                 java.lang.String name)
Returns a list of all Elements specified by name an prefix. An empty prefix will be interpreted as null by Element.

Parameters:
prefix - the namespace prefix of the elements to look for
name - the name of the elements to look for
Returns:
a deque with all subtrees containing this element to retain the structural data

findByName

public ItsTree<T> findByName(java.lang.String prefix,
                             java.lang.String name)
Returns the first Element, that is matched by prefix and the name

Parameters:
prefix - the namespace prefix of the Element
name - the elements name
Returns:
the first matching subtree containg the desired element

nextSibling

public ItsTree<T> nextSibling()
Returns the next sibling

Returns:
the next sibling

hasNextSibling

public boolean hasNextSibling()
Returns true, if it has a next sibling

Returns:

print

public java.lang.String print()
prints the tree with an intendation level

Returns:
the tree as string

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object