Style Intelligence v12.0

inetsoft.uql
Class XNode

java.lang.Object
  extended by inetsoft.uql.XNode
All Implemented Interfaces:
Serializable, Cloneable, Comparable
Direct Known Subclasses:
XSequenceNode, XTableNode, XTypeNode, XValueNode

public class XNode
extends Object
implements Serializable, Cloneable, Comparable

All query results are represented as a tree. A result tree is consisted of hierarchy of XNode objects. Each node has a name and a value. A non-leaf node has a list of children nodes. The XNode is the base class for all other node classes.

See Also:
Serialized Form

Field Summary
protected  Object value
           
 
Constructor Summary
XNode()
          Create an empty node.
XNode(String name)
          Create an empty node with the specified name.
 
Method Summary
 void addChild(XNode child)
          Add a child to this node.
 void addChild(XNode child, boolean sorted)
          Add a child to this node.
 void addChild(XNode child, boolean sorted, boolean uniq)
          Add a child to this node.
 int addr()
          Get the address of this node.
protected  XNode checkDuplicate(XNode child)
          This method is used to check if a child already exist with the same name.
 Object clone()
          Clone the object.
protected  void cloneValue(XNode node)
          Clone node value when necessary, do nothing by default.
 int compareTo(Object obj)
          Compares this object with the specified object for order.
 boolean eq(Object obj)
          Check if equals another object in content.
 boolean equals(Object obj)
          Compare if two nodes are equal.
 Object getAttribute(Object key)
          Get a node attribute value.
 Enumeration getAttributeNames()
          Get all attribute names.
 XNode getChild(int idx)
          Get the specified child node.
 XNode getChild(String name)
          Get the child node of this node with the specified name.
 int getChildCount()
          Get the number of children under this node.
 int getChildIndex(XNode child)
          Find the index of the child in this node.
 Format getDefaultFormat()
          Get the default format.
 String getName()
          Get the node name.
 XNode getNode(String path)
          Find the node specified by the node path.
 XNode getParent()
          Get the parent of this node.
 String getPath()
          Get the full path of this node.
 String getPath(XNode root)
          Get the full path of this node.
 Object getValue()
          Get the node value.
 Object getValue(String path)
          Get the value of a node.
 int hashCode()
          Calculate hash code of a node.
 void insertChild(int idx, XNode child)
          Insert a child to this node at the specified position.
 boolean isAncestor(XNode node)
          Check if this node is the ancestor of another node.
 void removeAllChildren()
          Remove all child in the tree.
 void removeChild(int idx)
          Remove the specified child.
 void removeChild(int idx, boolean permanent)
          Remove the specified child.
 void removeChild(XNode child)
          Remove the specified child.
 void removeChild(XNode child, boolean permanent)
          Remove the specified child.
 void setAttribute(Object key, Object val)
          Define an attribute and its value.
 void setChild(int idx, XNode child)
          Set the specified child of this node to the new child.
 void setDefaultFormat(Format format)
          Set the default format.
 void setName(String name)
          Set the node name.
 void setValue(Object value)
          Set the node value.
 void sort(boolean ascending)
          Sorts the children of this node by their names in the specified order.
 void sort(boolean ascending, boolean ignoreCase)
          Sorts the children of this node by their names in the specified order.
 String toString()
           
 void writeXML(PrintWriter writer)
          Write the node XML representation.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

value

protected Object value
Constructor Detail

XNode

public XNode()
Create an empty node.


XNode

public XNode(String name)
Create an empty node with the specified name.

Parameters:
name - node name.
Method Detail

getValue

public Object getValue(String path)
Get the value of a node. The node is specified by the node path. The node path can refer to the current node, or one of its child node. Each node in a tree is uniquely identified by a node path. When there are multiple nodes with the same name on the same level of a subtree, the nodes are grouped in a sequence node. Each node in a sequence can be uniquely identified by its index in the sequence, e.g. parent.seq[2].

Parameters:
path - node path.
Returns:
node value.

getNode

public XNode getNode(String path)
Find the node specified by the node path. The path is a dot delimited concatenation of node names from the root of the tree to the node. The child of a sequence node is refered to as the name of the sequence node followed by a sequence index, params[2].


getPath

public String getPath()
Get the full path of this node. The full path is the names from the root node to this node separated by dots.


getPath

public String getPath(XNode root)
Get the full path of this node. The full path is the names from the root node to this node separated by dots.

Parameters:
root - root is the root node of the tree. This can be used to get the path of a node in a subtree, which has a root that is a child of another node on the original tree.

getName

public String getName()
Get the node name.


setName

public void setName(String name)
Set the node name.


setValue

public void setValue(Object value)
Set the node value.


getValue

public Object getValue()
Get the node value.


getAttribute

public Object getAttribute(Object key)
Get a node attribute value. If the attribute is not defined, it returns null.

Parameters:
key - attribute key.
Returns:
attribute value.

setAttribute

public void setAttribute(Object key,
                         Object val)
Define an attribute and its value.

Parameters:
key - attribute key.
val - attribute value.

getAttributeNames

public Enumeration getAttributeNames()
Get all attribute names.


getChildCount

public int getChildCount()
Get the number of children under this node.


getChild

public XNode getChild(int idx)
Get the specified child node.

Parameters:
idx - child index.
Returns:
child node.

getChild

public XNode getChild(String name)
Get the child node of this node with the specified name.


getChildIndex

public int getChildIndex(XNode child)
Find the index of the child in this node.


addChild

public void addChild(XNode child)
Add a child to this node.


addChild

public void addChild(XNode child,
                     boolean sorted)
Add a child to this node.

Parameters:
child - child node.
sorted - true to add child in sorted order.

addChild

public void addChild(XNode child,
                     boolean sorted,
                     boolean uniq)
Add a child to this node.

Parameters:
child - child node.
sorted - true to add child in sorted order.
uniq - true to ensure the new child is unique. If child with same same exists, create a sequence node and add all nodes with same name to the sequence node.

checkDuplicate

protected XNode checkDuplicate(XNode child)
This method is used to check if a child already exist with the same name. If yes, it creates a sequence node to store the duplicate nodes.


setChild

public void setChild(int idx,
                     XNode child)
Set the specified child of this node to the new child.


removeChild

public void removeChild(XNode child)
Remove the specified child.


removeChild

public void removeChild(XNode child,
                        boolean permanent)
Remove the specified child.

Parameters:
permanent - true if the caller intends to remove the child permanently. Setting this parameter to true will remove all references to the child's parent and the child's children.

removeChild

public void removeChild(int idx)
Remove the specified child.

Parameters:
idx - the index of the child to remove

removeChild

public void removeChild(int idx,
                        boolean permanent)
Remove the specified child.

Parameters:
idx - the index of the child to remove
permanent - true if the caller intends to remove the child permanently. Setting this parameter to true will remove all references to the child's parent and the child's children.

removeAllChildren

public void removeAllChildren()
Remove all child in the tree.


insertChild

public void insertChild(int idx,
                        XNode child)
Insert a child to this node at the specified position.


getParent

public XNode getParent()
Get the parent of this node. If this node is the root node, it returns null.


isAncestor

public boolean isAncestor(XNode node)
Check if this node is the ancestor of another node.

Parameters:
node - the specified node.
Returns:
true if is the ancestor of the node, false otherwise.

writeXML

public void writeXML(PrintWriter writer)
Write the node XML representation.


toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Compare if two nodes are equal. Two nodes are considered equal if they have same name.

Overrides:
equals in class Object

hashCode

public int hashCode()
Calculate hash code of a node.

Overrides:
hashCode in class Object

addr

public int addr()
Get the address of this node.


eq

public boolean eq(Object obj)
Check if equals another object in content.


clone

public Object clone()
Clone the object.

Overrides:
clone in class Object

cloneValue

protected void cloneValue(XNode node)
Clone node value when necessary, do nothing by default.


compareTo

public int compareTo(Object obj)
Compares this object with the specified object for order.

Specified by:
compareTo in interface Comparable
Parameters:
obj - the object with which to compare.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

sort

public void sort(boolean ascending,
                 boolean ignoreCase)
Sorts the children of this node by their names in the specified order.

Parameters:
ascending - true to sort the children in ascending order; false to sort the children in descending order.

sort

public void sort(boolean ascending)
Sorts the children of this node by their names in the specified order.

Parameters:
ascending - true to sort the children in ascending order; false to sort the children in descending order.

getDefaultFormat

public Format getDefaultFormat()
Get the default format.


setDefaultFormat

public void setDefaultFormat(Format format)
Set the default format.


Copyright © 1996-2014 InetSoft Technology Corp. All Rights Reserved.