Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.xpath
Class XPath  view XPath download XPath.java

java.lang.Object
  extended byorg.apache.xpath.XPath
All Implemented Interfaces:
ExpressionOwner, java.io.Serializable

public class XPath
extends java.lang.Object
implements java.io.Serializable, ExpressionOwner

The XPath class wraps an expression object and provides general services for execution of that expression.


Field Summary
private static boolean DEBUG_MATCHES
          Set to true to get diagnostic messages about the result of match pattern testing.
private  Expression m_mainExp
          The top of the expression tree.
(package private)  java.lang.String m_patternString
          The pattern string, mainly kept around for diagnostic purposes.
static int MATCH
          Represents a match type expression.
static double MATCH_SCORE_NODETEST
          The match score if the pattern consists of just a NodeTest.
static double MATCH_SCORE_NONE
          The match score if no match is made.
static double MATCH_SCORE_NSWILD
          The match score if the pattern pattern has the form NCName:*.
static double MATCH_SCORE_OTHER
          The match score if the pattern consists of something other than just a NodeTest or just a qname.
static double MATCH_SCORE_QNAME
          The match score if the pattern has the form of a QName optionally preceded by an @ character.
static int SELECT
          Represents a select type expression.
 
Constructor Summary
XPath(Expression expr)
          Construct an XPath object.
XPath(java.lang.String exprString, javax.xml.transform.SourceLocator locator, org.apache.xml.utils.PrefixResolver prefixResolver, int type)
          Construct an XPath object.
XPath(java.lang.String exprString, javax.xml.transform.SourceLocator locator, org.apache.xml.utils.PrefixResolver prefixResolver, int type, javax.xml.transform.ErrorListener errorListener)
          Construct an XPath object.
 
Method Summary
 void assertion(boolean b, java.lang.String msg)
          Tell the user of an assertion error, and probably throw an exception.
 boolean bool(XPathContext xctxt, int contextNode, org.apache.xml.utils.PrefixResolver namespaceContext)
          Given an expression and a context, evaluate the XPath and return the result.
 void callVisitors(ExpressionOwner owner, XPathVisitor visitor)
          This will traverse the heararchy, calling the visitor for each member.
 void error(XPathContext xctxt, int sourceNode, java.lang.String msg, java.lang.Object[] args)
          Tell the user of an error, and probably throw an exception.
 org.apache.xpath.objects.XObject execute(XPathContext xctxt, int contextNode, org.apache.xml.utils.PrefixResolver namespaceContext)
          Given an expression and a context, evaluate the XPath and return the result.
 org.apache.xpath.objects.XObject execute(XPathContext xctxt, org.w3c.dom.Node contextNode, org.apache.xml.utils.PrefixResolver namespaceContext)
          Given an expression and a context, evaluate the XPath and return the result.
 void fixupVariables(java.util.Vector vars, int globalsSize)
          This function is used to fixup variables from QNames to stack frame indexes at stylesheet build time.
 Expression getExpression()
          Get the raw Expression object that this class wraps.
 javax.xml.transform.SourceLocator getLocator()
          Get the SourceLocator on the expression object.
 double getMatchScore(XPathContext xctxt, int context)
          Get the match score of the given node.
 java.lang.String getPatternString()
          Return the XPath string associated with this object.
 void installFunction(java.lang.String name, int funcIndex, org.apache.xpath.functions.Function func)
          Install a built-in function.
 void setExpression(Expression exp)
          Set the raw expression object for this object.
 void warn(XPathContext xctxt, int sourceNode, java.lang.String msg, java.lang.Object[] args)
          Warn the user of an problem.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_mainExp

private Expression m_mainExp
The top of the expression tree.


m_patternString

java.lang.String m_patternString
The pattern string, mainly kept around for diagnostic purposes.


SELECT

public static final int SELECT
Represents a select type expression.

See Also:
Constant Field Values

MATCH

public static final int MATCH
Represents a match type expression.

See Also:
Constant Field Values

DEBUG_MATCHES

private static final boolean DEBUG_MATCHES
Set to true to get diagnostic messages about the result of match pattern testing.

See Also:
Constant Field Values

MATCH_SCORE_NONE

public static final double MATCH_SCORE_NONE
The match score if no match is made.

See Also:
Constant Field Values

MATCH_SCORE_QNAME

public static final double MATCH_SCORE_QNAME
The match score if the pattern has the form of a QName optionally preceded by an @ character.

See Also:
Constant Field Values

MATCH_SCORE_NSWILD

public static final double MATCH_SCORE_NSWILD
The match score if the pattern pattern has the form NCName:*.

See Also:
Constant Field Values

MATCH_SCORE_NODETEST

public static final double MATCH_SCORE_NODETEST
The match score if the pattern consists of just a NodeTest.

See Also:
Constant Field Values

MATCH_SCORE_OTHER

public static final double MATCH_SCORE_OTHER
The match score if the pattern consists of something other than just a NodeTest or just a qname.

See Also:
Constant Field Values
Constructor Detail

XPath

public XPath(java.lang.String exprString,
             javax.xml.transform.SourceLocator locator,
             org.apache.xml.utils.PrefixResolver prefixResolver,
             int type,
             javax.xml.transform.ErrorListener errorListener)
      throws javax.xml.transform.TransformerException
Construct an XPath object. (Needs review -sc) This method initializes an XPathParser/ Compiler and compiles the expression.


XPath

public XPath(java.lang.String exprString,
             javax.xml.transform.SourceLocator locator,
             org.apache.xml.utils.PrefixResolver prefixResolver,
             int type)
      throws javax.xml.transform.TransformerException
Construct an XPath object. (Needs review -sc) This method initializes an XPathParser/ Compiler and compiles the expression.


XPath

public XPath(Expression expr)
Construct an XPath object.

Method Detail

getExpression

public Expression getExpression()
Get the raw Expression object that this class wraps.

Specified by:
getExpression in interface ExpressionOwner

fixupVariables

public void fixupVariables(java.util.Vector vars,
                           int globalsSize)
This function is used to fixup variables from QNames to stack frame indexes at stylesheet build time.


setExpression

public void setExpression(Expression exp)
Set the raw expression object for this object.

Specified by:
setExpression in interface ExpressionOwner

getLocator

public javax.xml.transform.SourceLocator getLocator()
Get the SourceLocator on the expression object.


getPatternString

public java.lang.String getPatternString()
Return the XPath string associated with this object.


execute

public org.apache.xpath.objects.XObject execute(XPathContext xctxt,
                                                org.w3c.dom.Node contextNode,
                                                org.apache.xml.utils.PrefixResolver namespaceContext)
                                         throws javax.xml.transform.TransformerException
Given an expression and a context, evaluate the XPath and return the result.


execute

public org.apache.xpath.objects.XObject execute(XPathContext xctxt,
                                                int contextNode,
                                                org.apache.xml.utils.PrefixResolver namespaceContext)
                                         throws javax.xml.transform.TransformerException
Given an expression and a context, evaluate the XPath and return the result.


bool

public boolean bool(XPathContext xctxt,
                    int contextNode,
                    org.apache.xml.utils.PrefixResolver namespaceContext)
             throws javax.xml.transform.TransformerException
Given an expression and a context, evaluate the XPath and return the result.


getMatchScore

public double getMatchScore(XPathContext xctxt,
                            int context)
                     throws javax.xml.transform.TransformerException
Get the match score of the given node.


installFunction

public void installFunction(java.lang.String name,
                            int funcIndex,
                            org.apache.xpath.functions.Function func)
Install a built-in function.


warn

public void warn(XPathContext xctxt,
                 int sourceNode,
                 java.lang.String msg,
                 java.lang.Object[] args)
          throws javax.xml.transform.TransformerException
Warn the user of an problem.


assertion

public void assertion(boolean b,
                      java.lang.String msg)
Tell the user of an assertion error, and probably throw an exception.


error

public void error(XPathContext xctxt,
                  int sourceNode,
                  java.lang.String msg,
                  java.lang.Object[] args)
           throws javax.xml.transform.TransformerException
Tell the user of an error, and probably throw an exception.


callVisitors

public void callVisitors(ExpressionOwner owner,
                         XPathVisitor visitor)
This will traverse the heararchy, calling the visitor for each member. If the called visitor method returns false, the subtree should not be called.