java.io.Serializable
, NodeFilter
, XPath
public class DefaultXPath extends java.lang.Object implements XPath, NodeFilter, java.io.Serializable
Constructor | Description |
---|---|
DefaultXPath(java.lang.String text) |
Construct an XPath
|
Modifier and Type | Method | Description |
---|---|---|
boolean |
booleanValueOf(java.lang.Object context) |
Retrieve a boolean-value interpretation of this XPath expression when
evaluated against a given context.
|
java.lang.Object |
evaluate(java.lang.Object context) |
evaluate evaluates an XPath expression and returns the
result as an Object . |
protected java.lang.Object |
getCompareValue(Node node) |
DOCUMENT ME!
|
org.jaxen.FunctionContext |
getFunctionContext() |
DOCUMENT ME!
|
org.jaxen.NamespaceContext |
getNamespaceContext() |
DOCUMENT ME!
|
java.lang.String |
getText() |
Retrieve the textual XPath string used to initialize this Object
|
org.jaxen.VariableContext |
getVariableContext() |
DOCUMENT ME!
|
protected void |
handleJaxenException(org.jaxen.JaxenException exception) |
|
boolean |
matches(Node node) |
matches returns true if the given node matches the XPath
expression. |
java.lang.Number |
numberValueOf(java.lang.Object context) |
numberValueOf evaluates an XPath expression and returns
the numeric value of the XPath expression if the XPath expression results
is a number, or null if the result is not a number. |
protected static org.jaxen.XPath |
parse(java.lang.String text) |
|
protected void |
removeDuplicates(java.util.List<Node> list,
java.util.Map<Node,java.lang.Object> sortValues) |
Removes items from the list which have duplicate values
|
java.util.List<Node> |
selectNodes(java.lang.Object context) |
|
java.util.List<Node> |
selectNodes(java.lang.Object context,
XPath sortXPath) |
|
java.util.List<Node> |
selectNodes(java.lang.Object context,
XPath sortXPath,
boolean distinct) |
|
java.lang.Object |
selectObject(java.lang.Object context) |
selectObject evaluates an XPath expression and returns the
result as an Object . |
Node |
selectSingleNode(java.lang.Object context) |
|
void |
setFunctionContext(org.jaxen.FunctionContext functionContext) |
Sets the function context to be used when evaluating XPath expressions
|
void |
setNamespaceContext(org.jaxen.NamespaceContext namespaceContext) |
Sets the namespace context to be used when evaluating XPath expressions
|
void |
setNamespaceURIs(java.util.Map<java.lang.String,java.lang.String> map) |
Sets the current NamespaceContext from a Map where the keys are the
String namespace prefixes and the values are the namespace URIs.
|
protected void |
setNSContext(java.lang.Object context) |
|
void |
setVariableContext(org.jaxen.VariableContext variableContext) |
Sets the variable context to be used when evaluating XPath expressions
|
void |
sort(java.util.List<Node> list) |
sort sorts the given List of Nodes using this XPath
expression as a Comparator . |
void |
sort(java.util.List<Node> list,
boolean distinct) |
sort sorts the given List of Nodes using this XPath
expression as a Comparator and optionally removing duplicates. |
protected void |
sort(java.util.List<Node> list,
java.util.Map<Node,java.lang.Object> sortValues) |
Sorts the list based on the sortValues for each node
|
java.lang.String |
toString() |
|
java.lang.String |
valueOf(java.lang.Object context) |
valueOf evaluates this XPath expression and returns the
textual representation of the results using the XPath string() function. |
public DefaultXPath(java.lang.String text) throws InvalidXPathException
text
- DOCUMENT ME!InvalidXPathException
- DOCUMENT ME!public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getText()
public org.jaxen.FunctionContext getFunctionContext()
XPath
getFunctionContext
in interface XPath
public void setFunctionContext(org.jaxen.FunctionContext functionContext)
XPath
setFunctionContext
in interface XPath
functionContext
- DOCUMENT ME!public org.jaxen.NamespaceContext getNamespaceContext()
XPath
getNamespaceContext
in interface XPath
public void setNamespaceURIs(java.util.Map<java.lang.String,java.lang.String> map)
XPath
Map uris = new HashMap(); uris.put("SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/"); uris.put("m", "urn:xmethodsBabelFish"); XPath xpath = document .createXPath("SOAP-ENV:Envelope/SOAP-ENV:Body/m:BabelFish"); xpath.setNamespaceURIs(uris); Node babelfish = xpath.selectSingleNode(document);
setNamespaceURIs
in interface XPath
map
- the map containing the namespace mappingspublic void setNamespaceContext(org.jaxen.NamespaceContext namespaceContext)
XPath
setNamespaceContext
in interface XPath
namespaceContext
- DOCUMENT ME!public org.jaxen.VariableContext getVariableContext()
XPath
getVariableContext
in interface XPath
public void setVariableContext(org.jaxen.VariableContext variableContext)
XPath
setVariableContext
in interface XPath
variableContext
- DOCUMENT ME!public java.lang.Object evaluate(java.lang.Object context)
XPath
public java.lang.Object selectObject(java.lang.Object context)
XPath
selectObject
evaluates an XPath expression and returns the
result as an Object
. The object returned can either be a List
of Node
instances, a Node
instance, a String
or a Number
instance depending on the XPath expression.selectObject
in interface XPath
context
- is either a node or a list of nodes on which to evalute the
XPathList
of Node
instances, a Node
instance, a String
or a
Number
instance depending on the XPath expression.public java.util.List<Node> selectNodes(java.lang.Object context)
XPath
selectNodes
performs this XPath expression on the given
Node
or List
of Node
s instances appending all
the results together into a single list.selectNodes
in interface XPath
context
- is either a node or a list of nodes on which to evalute the
XPathpublic java.util.List<Node> selectNodes(java.lang.Object context, XPath sortXPath)
XPath
selectNodes
evaluates the XPath expression on the given
Node
or List
of Node
s and returns the result as
a List
of Node
s sorted by the sort XPath
expression.selectNodes
in interface XPath
context
- is either a node or a list of nodes on which to evalute the
XPathsortXPath
- is the XPath expression to sort byNode
instancespublic java.util.List<Node> selectNodes(java.lang.Object context, XPath sortXPath, boolean distinct)
XPath
selectNodes
evaluates the XPath expression on the given
Node
or List
of Node
s and returns the result as
a List
of Node
s sorted by the sort XPath
expression.selectNodes
in interface XPath
context
- is either a node or a list of nodes on which to evalute the
XPathsortXPath
- is the XPath expression to sort bydistinct
- specifies whether or not duplicate values of the sort
expression are allowed. If this parameter is true then only
distinct sort expressions values are included in the resultNode
instancespublic Node selectSingleNode(java.lang.Object context)
XPath
selectSingleNode
evaluates this XPath expression on the
given Node
or List
of Node
s and returns the
result as a single Node
instance.selectSingleNode
in interface XPath
context
- is either a node or a list of nodes on which to evalute the
XPathNode
instancepublic java.lang.String valueOf(java.lang.Object context)
XPath
valueOf
evaluates this XPath expression and returns the
textual representation of the results using the XPath string() function.public java.lang.Number numberValueOf(java.lang.Object context)
XPath
numberValueOf
evaluates an XPath expression and returns
the numeric value of the XPath expression if the XPath expression results
is a number, or null if the result is not a number.numberValueOf
in interface XPath
context
- is either a node or a list of nodes on which to evalute the
XPathpublic boolean booleanValueOf(java.lang.Object context)
XPath
boolean(..)
core function as defined in the XPath
specification. This means that an expression that selects zero nodes will
return false
, while an expression that selects
one-or-more nodes will return true
.booleanValueOf
in interface XPath
context
- The node, nodeset or Context object for evaluation. This value
can be nullpublic void sort(java.util.List<Node> list)
sort
sorts the given List of Nodes using this XPath
expression as a Comparator
.
public void sort(java.util.List<Node> list, boolean distinct)
sort
sorts the given List of Nodes using this XPath
expression as a Comparator
and optionally removing duplicates.
public boolean matches(Node node)
XPath
matches
returns true if the given node matches the XPath
expression. To be more precise when evaluating this XPath expression on
the given node the result set must include the node.matches
in interface NodeFilter
matches
in interface XPath
node
- DOCUMENT ME!protected void sort(java.util.List<Node> list, java.util.Map<Node,java.lang.Object> sortValues)
list
- DOCUMENT ME!sortValues
- DOCUMENT ME!protected void removeDuplicates(java.util.List<Node> list, java.util.Map<Node,java.lang.Object> sortValues)
list
- DOCUMENT ME!sortValues
- DOCUMENT ME!protected java.lang.Object getCompareValue(Node node)
node
- DOCUMENT ME!protected static org.jaxen.XPath parse(java.lang.String text)
protected void setNSContext(java.lang.Object context)
protected void handleJaxenException(org.jaxen.JaxenException exception) throws XPathException
XPathException