|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.saxon.xpath.XPathExpressionImpl
The JAXP XPathExpression interface represents a compiled XPath expression that can be repeatedly evaluated. This class is Saxon's implementation of that interface.
The class also includes some methods retained from Saxon's original XPath API. When these methods are used, the object contains the context node and other state, so it is not thread-safe.
Constructor Summary | |
protected |
XPathExpressionImpl(Expression exp,
Configuration config)
The constructor is protected, to ensure that instances can only be created using the createExpression() method of XPathEvaluator |
Method Summary | |
java.util.List |
evaluate()
Execute a prepared XPath expression, returning the results as a List. |
java.lang.String |
evaluate(org.xml.sax.InputSource inputSource)
Evaluate the XPath expression against an input source to obtain a string result |
java.lang.Object |
evaluate(org.xml.sax.InputSource inputSource,
javax.xml.namespace.QName qName)
Evaluate the XPath expression against an input source to obtain a result of a specified type |
java.lang.String |
evaluate(java.lang.Object node)
Evaluate the expression to return a string value |
java.lang.Object |
evaluate(java.lang.Object node,
javax.xml.namespace.QName qName)
JAXP 1.3 evaluate() method |
java.lang.Object |
evaluateSingle()
Execute a prepared XPath expression, returning the first item in the result. |
Expression |
getInternalExpression()
Low-level method to get the internal Saxon expression object. |
SequenceIterator |
rawIterator()
Get a raw iterator over the results of the expression. |
void |
setContextNode(NodeInfo node)
Set the context node for evaluating the expression. |
void |
setSortKey(XPathExpressionImpl sortKey)
Define the sort order for the results of the expression. |
protected void |
setStackFrameMap(SlotManager map)
Define the number of slots needed for local variables within the expression. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected XPathExpressionImpl(Expression exp, Configuration config)
Method Detail |
protected void setStackFrameMap(SlotManager map)
public void setSortKey(XPathExpressionImpl sortKey)
sortKey
- an XPathExpression, which will be applied to each item in the sequence;
the result of this expression determines the ordering of the list returned by the evaluate()
method. The sortKey can be null, to clear a previous sort key.public void setContextNode(NodeInfo node)
public java.util.List evaluate() throws XPathException
setContextNode(net.sf.saxon.om.NodeInfo)
.
evaluate(Object, javax.xml.namespace.QName)
with the second argument set to NODESET.
XPathException
public java.lang.Object evaluateSingle() throws XPathException
setContextNode(net.sf.saxon.om.NodeInfo)
.
XPathException
public SequenceIterator rawIterator() throws XPathException
XPathException
public java.lang.Object evaluate(java.lang.Object node, javax.xml.namespace.QName qName) throws javax.xml.xpath.XPathExpressionException
evaluate
in interface javax.xml.xpath.XPathExpression
node
- The context node. This must use a representation of nodes that this implementation understands.
This may be a Saxon NodeInfo, or a node in one of the external object models supported, for example
DOM, JDOM, or XOM, provided the support module for that object model is loaded.qName
- Indicates the type of result required. This must be one of the constants defined in
the JAXP XPathConstants
class.
Saxon will attempt to convert the actual result of the expression to the required type using the
XPath 1.0 conversion rules.
QName | Return Value |
BOOLEAN | The effective boolean value of the actual result, as a Java Boolean object |
STRING | The result of applying the string() function to the actual result, as a Java String object |
NUMBER | The result of applying the number() function to the actual result, as a Java Double object |
NODE | A single node, in the native data model supplied as input. If the expression returns more than one node, the first is returned. If the expression returns an empty sequence, null is returned. If the expression returns an atomic value, or if the first item in the result sequence is an atomic value, an exception is thrown. |
NODESET | This is interpreted as allowing any sequence, of nodes or atomic values. The result is returned as a Java List object, unless it is empty, in which case null is returned. The contents of the list may be node objects (in the native data model supplied as input, or Java objects representing the XPath atomic values in the actual result: String for an xs:string, Double for a xs:double, Long for an xs:integer, and so on. (For safety, cast the values to a type such as xs:string within the XPath expression). Note that the result is never returned as a DOM NodeList. |
javax.xml.xpath.XPathExpressionException
- if evaluation of the expression fails or if the
result cannot be converted to the requested type.public java.lang.String evaluate(java.lang.Object node) throws javax.xml.xpath.XPathExpressionException
evaluate
in interface javax.xml.xpath.XPathExpression
node
- the initial context node. This must be an instance of NodeInfo
javax.xml.xpath.XPathExpressionException
- if evaluation failspublic java.lang.Object evaluate(org.xml.sax.InputSource inputSource, javax.xml.namespace.QName qName) throws javax.xml.xpath.XPathExpressionException
evaluate
in interface javax.xml.xpath.XPathExpression
inputSource
- The input source document against which the expression is evaluated.
(Note that there is no caching. This will be parsed, and the parsed result will be discarded.)qName
- The type required, identified by a constant in XPathConstants
evaluate(Object, javax.xml.namespace.QName)
javax.xml.xpath.XPathExpressionException
public java.lang.String evaluate(org.xml.sax.InputSource inputSource) throws javax.xml.xpath.XPathExpressionException
evaluate
in interface javax.xml.xpath.XPathExpression
inputSource
- The input source document against which the expression is evaluated.
(Note that there is no caching. This will be parsed, and the parsed result will be discarded.)
javax.xml.xpath.XPathExpressionException
public Expression getInternalExpression()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |