| 
 | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.jaffa.util.Node
An instance of this class can represent a node in a tree. Each node will have a system generated unique identifier. It may have a name (which can be non-unique). It can be linked to a Parent node or be the Root of the tree. It can have child nodes. It will have a value Object. Additionally it can have a map of attributes.
| Constructor Summary | |
| Node()Creates new Node | |
| Node(String name)Creates new Node specifying a name. | |
| Method Summary | |
|  void | addChild(Node node)Adds a child node. | 
|  Object | getAttribute(Object key)Returns the attribute for the specified key. | 
|  Map | getAttributes()Getter for property attributes. | 
|  Node | getChildById(String id)Returns the child by id. | 
|  Node | getChildByName(String name)Returns the 1st child which matches the name. | 
|  Collection | getChildren()Returns a collection of child nodes. | 
|  Node | getFromFamilyById(String id)Returns a node from the family by id. | 
|  String | getId()Returns the unique identifier of the node. | 
|  String | getName()Getter for property name. | 
|  Node | getParent()Returns the Parent node, or null if this node has no parent. | 
|  Node | getRoot()Returns the root node of the tree to which this node belongs. | 
|  Object | getValue()Getter for property value. | 
|  boolean | hasChildren()Returns true if the node has childen. | 
|  boolean | isRoot()Returns true if the node is its own root. | 
| static void | main(String[] args)Test rig | 
|  void | makeRoot()Makes the node its own root. | 
|  boolean | parentHasMoreChildren()Returns true if the parent node has any more child nodes after the current node. | 
|  void | printNode(Writer writer)A helper routine to print the contents of a node. | 
|  void | printNode(Writer writer,
                   String pad,
                   String padIncrement)A helper routine to print the contents of a node. | 
|  Object | removeAttribute(Object key)Removes an attribute . | 
|  boolean | removeChild(Node node)Removes a child node. | 
|  boolean | removeChild(String name)Removes the 1st child that matches the name | 
|  boolean | removeChildren()Remove all children. | 
|  Object | setAttribute(Object key,
                         Object value)Adds an attribute. | 
|  void | setAttributes(Map attributes)Setter for property attributes. | 
|  void | setName(String name)Setter for property name. | 
|  void | setValue(Object value)Setter for property value. | 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
public Node()
public Node(String name)
name - The node name.| Method Detail | 
public String getId()
public Node getParent()
public Node getRoot()
public Collection getChildren()
public Node getChildByName(String name)
name - The node name.
public Node getChildById(String id)
id - The node identifier.
public Node getFromFamilyById(String id)
id - The node identifier.
public String getName()
public void setName(String name)
name - New value of property name.public Object getValue()
public void setValue(Object value)
value - New value of property value.public Map getAttributes()
public void setAttributes(Map attributes)
attributes - New value of property attributes.public Object getAttribute(Object key)
key - The attribute key.
public Object setAttribute(Object key,
                           Object value)
key - The attribute key.value - The attribute value.
public Object removeAttribute(Object key)
key - The attribute key.
public boolean isRoot()
public boolean hasChildren()
public boolean parentHasMoreChildren()
public void makeRoot()
public void addChild(Node node)
node - The child node.public boolean removeChild(Node node)
node - The child node.
public boolean removeChild(String name)
name - The node name.
public boolean removeChildren()
public void printNode(Writer writer)
               throws IOException
writer - The writer to which the node contents will be printed.
IOException - if any I/O error occurs.
public void printNode(Writer writer,
                      String pad,
                      String padIncrement)
               throws IOException
writer - The writer to which the node contents will be printed.pad - The pad string to be used.padIncrement - The increment string to be appended to the pad string at each successive level of child nodes.
IOException - if any I/O error occurs.public static void main(String[] args)
args - The arguments. Not used.| 
 | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||