jd.xml.xpath.tool
Class XPath

java.lang.Object
  extended byjd.xml.xpath.tool.XPath

public class XPath
extends Object

A utility class to evaluate XPath expressions.


Constructor Summary
XPath(Expression expr)
          Create a XPath object for the given Expression.
XPath(String expr)
          Create a XPath object for the given Expression string.
XPath(String expr, XPathNamespaces namespaces)
          Create a XPath object for the given Expression string.
 
Method Summary
 void clearVariable(String name)
          Clear a variable value.
 void clearVariables()
          Clear the variable values.
 XPathContext getContext()
          Return the evaluation context.
 Expression getExpression()
          Return the parsed XPath expression.
static void main(String[] args)
           
 void printResult(XObject result, XmlWriter out)
           
 void printVerboseResult(XObject result, XmlWriter out)
           
static int run(String[] args)
           
 void setContext(XPathNode contextNode)
          Set the evaluation context: The context nodes is set to the given node, the context size and position is set to 1.
 void setVariable(String name, boolean value)
          Set a variable to a boolean value.
 void setVariable(String name, double value)
          Set a variable to a number value.
 void setVariable(String name, String value)
          Set a variable to a String value.
 void setVariable(String name, XObject value)
          Set a variable to a generic value.
 boolean toBooleanValue()
          Evaluate the expression to a boolean value.
 XNodeSet toNodeSet()
          Evaluate the expression to a node-set.
 double toNumberValue()
          Evaluate the expression to a number value.
 String toStringValue()
          Evaluate the expression to a String value.
 XObject toXObject()
          Evaluate the expression to a generic XPath object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XPath

public XPath(String expr)
      throws XPathParseException
Create a XPath object for the given Expression string. The expression may not contain node-tests which non null namespace uris.

Throws:
XPathParseException - if the expression string cannot be parsed.

XPath

public XPath(String expr,
             XPathNamespaces namespaces)
      throws XPathParseException
Create a XPath object for the given Expression string.

Throws:
XPathParseException - if the expression string cannot be parsed.

XPath

public XPath(Expression expr)
Create a XPath object for the given Expression.

Method Detail

getExpression

public Expression getExpression()
Return the parsed XPath expression.


setVariable

public void setVariable(String name,
                        boolean value)
Set a variable to a boolean value.


setVariable

public void setVariable(String name,
                        String value)
Set a variable to a String value.


setVariable

public void setVariable(String name,
                        double value)
Set a variable to a number value.


setVariable

public void setVariable(String name,
                        XObject value)
Set a variable to a generic value.


clearVariables

public void clearVariables()
Clear the variable values.


clearVariable

public void clearVariable(String name)
Clear a variable value.


setContext

public void setContext(XPathNode contextNode)
Set the evaluation context: The context nodes is set to the given node, the context size and position is set to 1.


getContext

public XPathContext getContext()
Return the evaluation context. You can use the context to set the context node, position and size.


toBooleanValue

public boolean toBooleanValue()
Evaluate the expression to a boolean value.


toStringValue

public String toStringValue()
Evaluate the expression to a String value.


toNumberValue

public double toNumberValue()
Evaluate the expression to a number value.


toNodeSet

public XNodeSet toNodeSet()
Evaluate the expression to a node-set.


toXObject

public XObject toXObject()
Evaluate the expression to a generic XPath object.


printVerboseResult

public void printVerboseResult(XObject result,
                               XmlWriter out)

printResult

public void printResult(XObject result,
                        XmlWriter out)
                 throws IOException
Throws:
IOException

run

public static int run(String[] args)
               throws Exception
Throws:
Exception

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception