tiger.util
Class Tree

java.lang.Object
  |
  +--tiger.util.Tree
All Implemented Interfaces:
java.io.Serializable

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

Simple class for representing a tree.

Author:
Fredrik Bertilsson
See Also:
Serialized Form

Constructor Summary
Tree()
           
Tree(org.w3c.dom.Node aNode)
           
Tree(java.lang.Object aKey)
          Constructs a tree with specified root key and empty value.
Tree(java.lang.Object aKey, java.lang.Object aValue)
          Constructs a tree with specified root key and root value.
 
Method Summary
 Tree addChild(java.lang.Object aKey)
          Adds a childtree to this tree and returns a reference to that tree.
 Tree addChild(java.lang.Object aKey, java.lang.Object aValue)
          Adds a childtree to this tree and returns a reference to that tree.
 Tree addChild(Tree aChildTree)
          Adds a childtree to this tree and returns a reference to that tree.
static Tree createTreeByDOM(java.io.Reader aReader)
           
static Tree createTreeBySAX(java.io.Reader aReader)
           
 java.util.Set getChildKeys()
           
 java.util.Map getChildrenMap()
          Returns the Map representing the children.
 Tree getChildTree(java.lang.Object aKey)
          Returns the child tree with specified key.
 java.lang.Object getChildValue(java.lang.Object aKey)
           
 java.lang.Object getKey()
          Returns the root key for this tree.
 java.lang.Object getObject()
          Returns value if exists, otherwise returns key.
 java.lang.Object getPathValue(java.lang.String aPath)
          Returns a value associated for a specified node.
 java.lang.Object getValue()
          Returns the root value for this tree.
 java.lang.Object getValue(Path aPath)
          Returns the value associated with the node specified by the given path.
 java.lang.Object getValueUseParent(Path aPath)
           
 boolean isLeaf()
          Checks if the tree is a leaf (does not have any children).
 void put(java.util.Map aMap)
           
 void put(java.lang.Object aKey, java.util.Map aMap)
           
 void put(java.lang.Object aKey, java.lang.Object aValue)
           
 void put(Path aPath, java.util.Map aMap)
           
 void put(Path aPath, java.lang.Object aValue)
          Puts a mapping between a path and value.
 void remove(Path aPath)
           
 void removeIfExists(Path aPath)
           
 void setCheckExistence(boolean aCheckExistanceFlag)
           
 void setValue(java.lang.Object aValue)
          Sets the value.
 java.lang.String toString()
           
 java.lang.String toString(java.lang.String aPrefix)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Tree

public Tree(java.lang.Object aKey,
            java.lang.Object aValue)
Constructs a tree with specified root key and root value.


Tree

public Tree(java.lang.Object aKey)
Constructs a tree with specified root key and empty value.


Tree

public Tree()

Tree

public Tree(org.w3c.dom.Node aNode)
Method Detail

createTreeByDOM

public static Tree createTreeByDOM(java.io.Reader aReader)

createTreeBySAX

public static Tree createTreeBySAX(java.io.Reader aReader)

getKey

public java.lang.Object getKey()
Returns the root key for this tree.


getValue

public java.lang.Object getValue()
Returns the root value for this tree.


setValue

public void setValue(java.lang.Object aValue)
Sets the value.


getObject

public java.lang.Object getObject()
Returns value if exists, otherwise returns key.


getChildTree

public Tree getChildTree(java.lang.Object aKey)
Returns the child tree with specified key.


put

public void put(Path aPath,
                java.lang.Object aValue)
Puts a mapping between a path and value.

Parameters:
aPath - Path
aValue - Value

put

public void put(Path aPath,
                java.util.Map aMap)

put

public void put(java.lang.Object aKey,
                java.util.Map aMap)

put

public void put(java.util.Map aMap)

put

public void put(java.lang.Object aKey,
                java.lang.Object aValue)

getPathValue

public java.lang.Object getPathValue(java.lang.String aPath)
Returns a value associated for a specified node.


getValue

public java.lang.Object getValue(Path aPath)
Returns the value associated with the node specified by the given path.


getValueUseParent

public java.lang.Object getValueUseParent(Path aPath)

addChild

public Tree addChild(java.lang.Object aKey,
                     java.lang.Object aValue)
Adds a childtree to this tree and returns a reference to that tree.


addChild

public Tree addChild(java.lang.Object aKey)
Adds a childtree to this tree and returns a reference to that tree.


addChild

public Tree addChild(Tree aChildTree)
Adds a childtree to this tree and returns a reference to that tree.


remove

public void remove(Path aPath)

removeIfExists

public void removeIfExists(Path aPath)

isLeaf

public boolean isLeaf()
Checks if the tree is a leaf (does not have any children).


getChildKeys

public java.util.Set getChildKeys()

getChildValue

public java.lang.Object getChildValue(java.lang.Object aKey)

getChildrenMap

public java.util.Map getChildrenMap()
Returns the Map representing the children.


setCheckExistence

public void setCheckExistence(boolean aCheckExistanceFlag)

toString

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

toString

public java.lang.String toString(java.lang.String aPrefix)