Style Intelligence v12.0

inetsoft.uql.path
Class XNodePath

java.lang.Object
  extended by inetsoft.uql.path.XNodePath
All Implemented Interfaces:
Serializable, Cloneable

public class XNodePath
extends Object
implements Serializable, Cloneable

A node path is used to perform tree selections. It can be used to select a subtree from a xnode tree. The selection can be done using only node path, or mixed with conditions at any sequence node. A simple node path is the node name concatenated together from the root of the tree, separated by dots:

  employee.name
 A condition can be attached to a node:
  employee[state = 'NJ'].name
 

See Also:
Serialized Form

Constructor Summary
XNodePath()
          Create an empty node path.
 
Method Summary
 void add(PathNode node)
          Add a node to the node path.
 void add(String name)
          Add a node to the path.
 void add(String name, ConditionExpression cond)
          Add a node to the path with an additional condition to select nodes from the sequence.
 void add(String name, String cond)
          Add a node to the path with an additional condition to select nodes from the sequence.
 Object clone()
          Returns a clone of this object.
 PathNode find(XTypeNode root, XTypeNode node)
          Check if the node specified by the type is on the node path.
 String getPath(PathNode node)
          This get the path of the nodes.
 PathNode getPathNode(int idx)
          Get the specified node.
 int getPathNodeCount()
          Get the number of nodes from the path.
 String[] getVariables()
          Get the names of all variables used in the conditions in the path.
static XNodePath parse(String path)
          Parse a node path string and create a node path object.
static XNodePath parseSimplePath(String path)
          Parse a simple path that is a concatenation of node names without any condition expression.
 void parseXML(Element root)
          Parse the XML element that contains information of this node path.
 XNode select(XNode root, VariableTable vars)
          Apply the path to the tree, and return selected nodes from the tree.
 void setPathNode(int idx, PathNode node)
          Set the node at the specified index.
 String toString()
           
 void writeXML(PrintWriter writer)
          Write node path in XML representation.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XNodePath

public XNodePath()
Create an empty node path.

Method Detail

parse

public static XNodePath parse(String path)
                       throws ParseException
Parse a node path string and create a node path object.

Throws:
ParseException

parseSimplePath

public static XNodePath parseSimplePath(String path)
Parse a simple path that is a concatenation of node names without any condition expression.


select

public XNode select(XNode root,
                    VariableTable vars)
             throws Exception
Apply the path to the tree, and return selected nodes from the tree.

Parameters:
root - tree root.
vars - query variables.
Returns:
root of selected nodes.
Throws:
Exception

getVariables

public String[] getVariables()
Get the names of all variables used in the conditions in the path.


find

public PathNode find(XTypeNode root,
                     XTypeNode node)
Check if the node specified by the type is on the node path.

Returns:
the matching node.

getPathNodeCount

public int getPathNodeCount()
Get the number of nodes from the path.


getPathNode

public PathNode getPathNode(int idx)
Get the specified node.

Parameters:
idx - node index.
Returns:
specified path node.

setPathNode

public void setPathNode(int idx,
                        PathNode node)
Set the node at the specified index.

Parameters:
idx - node index.
node - new path node.

add

public void add(String name)
Add a node to the path.


add

public void add(String name,
                String cond)
         throws ParseException
Add a node to the path with an additional condition to select nodes from the sequence.

Throws:
ParseException

add

public void add(String name,
                ConditionExpression cond)
Add a node to the path with an additional condition to select nodes from the sequence.


add

public void add(PathNode node)
Add a node to the node path.


getPath

public String getPath(PathNode node)
This get the path of the nodes. The node condition is not included in the path.

Parameters:
node - the path node this path should include. Nodes following the node is not added to the path. If the node is null, all nodes are included.

toString

public String toString()
Overrides:
toString in class Object

writeXML

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


parseXML

public void parseXML(Element root)
              throws Exception
Parse the XML element that contains information of this node path.

Throws:
Exception

clone

public Object clone()
Returns a clone of this object.

Overrides:
clone in class Object

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