org.jaxen.javabean
Class JavaBeanXPath
java.lang.Object
org.jaxen.BaseXPath
org.jaxen.javabean.JavaBeanXPath
- All Implemented Interfaces:
- java.io.Serializable, XPath
- public class JavaBeanXPath
- extends BaseXPath
An XPath implementation for JavaBeans.
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);
- Version:
- $Revision: 1.6 $
- Author:
- bob mcwhirter
- See Also:
BaseXPath
,
Serialized Form
Fields inherited from class org.jaxen.BaseXPath |
|
Constructor Summary |
JavaBeanXPath(java.lang.String xpathExpr)
Construct given an XPath expression string. |
Method Summary |
java.lang.Object |
evaluate(java.lang.Object node)
Evaluate this XPath against a given context. |
protected Context |
getContext(java.lang.Object node)
Create a Context wrapper for the provided
implementation-specific object. |
Methods inherited from class org.jaxen.BaseXPath |
addNamespace, booleanValueOf, createFunctionContext, createNamespaceContext, createVariableContext, debug, getContextSupport, getFunctionContext, getNamespaceContext, getNavigator, getRootExpr, getVariableContext, numberValueOf, selectNodes, selectNodesForContext, selectSingleNode, selectSingleNodeForContext, setFunctionContext, setNamespaceContext, setVariableContext, stringValueOf, toString, valueOf |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
JavaBeanXPath
public JavaBeanXPath(java.lang.String xpathExpr)
throws JaxenException
- Construct given an XPath expression string.
- Parameters:
xpathExpr
- The XPath expression.
- Throws:
JaxenException
- if there is a syntax error while
parsing the expression
getContext
protected Context getContext(java.lang.Object node)
- Description copied from class:
BaseXPath
- Create a
Context
wrapper for the provided
implementation-specific object.
- Overrides:
getContext
in class BaseXPath
- Parameters:
node
- the implementation-specific object
to be used as the context
- Returns:
- a
Context
wrapper around the object
evaluate
public java.lang.Object evaluate(java.lang.Object node)
throws JaxenException
- Description copied from class:
BaseXPath
- Evaluate this XPath against a given context.
The context of evaluation may be any object type
the navigator recognizes as a node.
The return value is either a
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.
- Specified by:
evaluate
in interface XPath
- Overrides:
evaluate
in class BaseXPath
- Parameters:
node
- the node, node-set or Context object for evaluation.
This value can be null.
- Returns:
- the result of evaluating the XPath expression
against the supplied context
- Throws:
JaxenException
- if an XPath error occurs during expression evaluation