public class JavaBeanXPath extends BaseXPath
This is the main entry point for matching an XPath against a JavaBean
tree. You create a compiled XPath object, then match it against
one or more context nodes using the BaseXPath.selectNodes(Object)
method, as in the following example:
Node node = ...; XPath path = new JavaBeanXPath("a/b/c"); List results = path.selectNodes(node);
BaseXPath
,
Serialized FormConstructor and Description |
---|
JavaBeanXPath(String xpathExpr)
Construct given an XPath expression string.
|
Modifier and Type | Method and Description |
---|---|
Object |
evaluate(Object node)
Evaluate this XPath against a given context.
|
protected Context |
getContext(Object node)
Create a
Context wrapper for the provided
implementation-specific object. |
addNamespace, booleanValueOf, createFunctionContext, createNamespaceContext, createVariableContext, debug, getContextSupport, getFunctionContext, getNamespaceContext, getNavigator, getRootExpr, getVariableContext, numberValueOf, selectNodes, selectNodesForContext, selectSingleNode, selectSingleNodeForContext, setFunctionContext, setNamespaceContext, setVariableContext, stringValueOf, toString
public JavaBeanXPath(String xpathExpr) throws JaxenException
xpathExpr
- the XPath expressionJaxenException
- if there is a syntax error while
parsing the expressionprotected Context getContext(Object node)
BaseXPath
Context
wrapper for the provided
implementation-specific object.getContext
in class BaseXPath
node
- the implementation-specific object
to be used as the contextContext
wrapper around the objectpublic Object evaluate(Object node) throws JaxenException
BaseXPath
String
,
Double
, Boolean
, or List
of nodes.
When using this method, one must be careful to
test the class of the returned object. If the returned
object is a list, then the items in this
list will be the actual Document
,
Element
, Attribute
, etc. objects
as defined by the concrete XML object-model implementation,
directly from the context document. This method does
not return copies of anything, but merely
returns references to objects within the source document.
evaluate
in interface XPath
evaluate
in class BaseXPath
node
- the node, node-set or Context object for evaluation.
This value can be null.JaxenException
- if an XPath error occurs during expression evaluationCopyright 2001–2022 The Jaxen Project. All rights reserved.