|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.xpath.XPath
public class XPath
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 FunctionTable |
m_funcTable
The function table for xpath build-in functions |
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. |
(package private) static long |
serialVersionUID
|
Constructor Summary | |
---|---|
XPath(Expression expr)
Construct an XPath object. |
|
XPath(java.lang.String exprString,
javax.xml.transform.SourceLocator locator,
PrefixResolver prefixResolver,
int type)
Construct an XPath object. |
|
XPath(java.lang.String exprString,
javax.xml.transform.SourceLocator locator,
PrefixResolver prefixResolver,
int type,
javax.xml.transform.ErrorListener errorListener)
Construct an XPath object. |
|
XPath(java.lang.String exprString,
javax.xml.transform.SourceLocator locator,
PrefixResolver prefixResolver,
int type,
javax.xml.transform.ErrorListener errorListener,
FunctionTable aTable)
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,
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. |
XObject |
execute(XPathContext xctxt,
int contextNode,
PrefixResolver namespaceContext)
Given an expression and a context, evaluate the XPath and return the result. |
XObject |
execute(XPathContext xctxt,
org.w3c.dom.Node contextNode,
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. |
private void |
initFunctionTable()
initial the function table |
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 |
---|
static final long serialVersionUID
private Expression m_mainExp
private transient FunctionTable m_funcTable
java.lang.String m_patternString
public static final int SELECT
public static final int MATCH
private static final boolean DEBUG_MATCHES
public static final double MATCH_SCORE_NONE
public static final double MATCH_SCORE_QNAME
public static final double MATCH_SCORE_NSWILD
public static final double MATCH_SCORE_NODETEST
public static final double MATCH_SCORE_OTHER
Constructor Detail |
---|
public XPath(java.lang.String exprString, javax.xml.transform.SourceLocator locator, PrefixResolver prefixResolver, int type, javax.xml.transform.ErrorListener errorListener) throws javax.xml.transform.TransformerException
exprString
- The XPath expression.locator
- The location of the expression, may be null.prefixResolver
- A prefix resolver to use to resolve prefixes to
namespace URIs.type
- one of SELECT
or MATCH
.errorListener
- The error listener, or null if default should be used.
javax.xml.transform.TransformerException
- if syntax or other error.public XPath(java.lang.String exprString, javax.xml.transform.SourceLocator locator, PrefixResolver prefixResolver, int type, javax.xml.transform.ErrorListener errorListener, FunctionTable aTable) throws javax.xml.transform.TransformerException
exprString
- The XPath expression.locator
- The location of the expression, may be null.prefixResolver
- A prefix resolver to use to resolve prefixes to
namespace URIs.type
- one of SELECT
or MATCH
.errorListener
- The error listener, or null if default should be used.
javax.xml.transform.TransformerException
- if syntax or other error.public XPath(java.lang.String exprString, javax.xml.transform.SourceLocator locator, PrefixResolver prefixResolver, int type) throws javax.xml.transform.TransformerException
exprString
- The XPath expression.locator
- The location of the expression, may be null.prefixResolver
- A prefix resolver to use to resolve prefixes to
namespace URIs.type
- one of SELECT
or MATCH
.
javax.xml.transform.TransformerException
- if syntax or other error.public XPath(Expression expr)
expr
- The Expression object.
javax.xml.transform.TransformerException
- if syntax or other error.Method Detail |
---|
private void initFunctionTable()
public Expression getExpression()
getExpression
in interface ExpressionOwner
public void fixupVariables(java.util.Vector vars, int globalsSize)
vars
- List of QNames that correspond to variables. This list
should be searched backwards for the first qualified name that
corresponds to the variable reference qname. The position of the
QName in the vector from the start of the vector will be its position
in the stack frame (but variables above the globalsTop value will need
to be offset to the current stack frame).public void setExpression(Expression exp)
setExpression
in interface ExpressionOwner
exp
- the raw Expression object, which should not normally be null.public javax.xml.transform.SourceLocator getLocator()
public java.lang.String getPatternString()
public XObject execute(XPathContext xctxt, org.w3c.dom.Node contextNode, PrefixResolver namespaceContext) throws javax.xml.transform.TransformerException
xctxt
- The execution context.contextNode
- The node that "." expresses.namespaceContext
- The context in which namespaces in the
XPath are supposed to be expanded.
javax.xml.transform.TransformerException
- thrown if
the error condition is severe enough to halt processing.
javax.xml.transform.TransformerException
public XObject execute(XPathContext xctxt, int contextNode, PrefixResolver namespaceContext) throws javax.xml.transform.TransformerException
xctxt
- The execution context.contextNode
- The node that "." expresses.namespaceContext
- The context in which namespaces in the
XPath are supposed to be expanded.
javax.xml.transform.TransformerException
- thrown if the active ProblemListener decides
the error condition is severe enough to halt processing.
javax.xml.transform.TransformerException
public boolean bool(XPathContext xctxt, int contextNode, PrefixResolver namespaceContext) throws javax.xml.transform.TransformerException
xctxt
- The execution context.contextNode
- The node that "." expresses.namespaceContext
- The context in which namespaces in the
XPath are supposed to be expanded.
javax.xml.transform.TransformerException
- thrown if the active ProblemListener decides
the error condition is severe enough to halt processing.
javax.xml.transform.TransformerException
public double getMatchScore(XPathContext xctxt, int context) throws javax.xml.transform.TransformerException
xctxt
- XPath runtime context.context
- The current source tree context node.
MATCH_SCORE_NODETEST
,
MATCH_SCORE_NONE
, MATCH_SCORE_OTHER
,
or MATCH_SCORE_QNAME
.
javax.xml.transform.TransformerException
public void warn(XPathContext xctxt, int sourceNode, java.lang.String msg, java.lang.Object[] args) throws javax.xml.transform.TransformerException
xctxt
- The XPath runtime context.sourceNode
- Not used.msg
- An error msgkey that corresponds to one of the constants found
in XPATHErrorResources
, which is
a key for a format string.args
- An array of arguments represented in the format string, which
may be null.
javax.xml.transform.TransformerException
- if the current ErrorListoner determines to
throw an exception.public void assertion(boolean b, java.lang.String msg)
b
- If false, a runtime exception will be thrown.msg
- The assertion message, which should be informative.
java.lang.RuntimeException
- if the b argument is false.public void error(XPathContext xctxt, int sourceNode, java.lang.String msg, java.lang.Object[] args) throws javax.xml.transform.TransformerException
xctxt
- The XPath runtime context.sourceNode
- Not used.msg
- An error msgkey that corresponds to one of the constants found
in XPATHErrorResources
, which is
a key for a format string.args
- An array of arguments represented in the format string, which
may be null.
javax.xml.transform.TransformerException
- if the current ErrorListoner determines to
throw an exception.public void callVisitors(ExpressionOwner owner, XPathVisitor visitor)
owner
- The owner of the visitor, where that path may be
rewritten if needed.visitor
- The visitor whose appropriate method will be called.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |