public class DefaultXPath extends Object implements XPath, NodeFilter, Serializable
Modifier and Type | Field and Description |
---|---|
private org.jaxen.NamespaceContext |
namespaceContext |
private String |
text |
private org.jaxen.BaseXPath |
xpath |
Constructor and Description |
---|
DefaultXPath(String text)
Construct an XPath
|
Modifier and Type | Method and Description |
---|---|
Object |
evaluate(Object context)
evaluate evaluates an XPath expression and returns
the result as an Object . |
protected Object |
getCompareValue(Node node) |
org.jaxen.FunctionContext |
getFunctionContext() |
org.jaxen.NamespaceContext |
getNamespaceContext() |
String |
getText()
Retrieve the textual XPath string used to initialize this Object
|
org.jaxen.VariableContext |
getVariableContext() |
protected void |
handleJaxenException(org.jaxen.JaxenException e) |
boolean |
matches(Node node)
matches returns true if the given node matches
the XPath expression. |
Number |
numberValueOf(Object context)
numberValueOf evaluates an XPath expression
and returns the numeric value of the XPath expression if the XPath
expression results in a number, or null if the result is not a number. |
protected static org.jaxen.BaseXPath |
parse(String text) |
protected void |
removeDuplicates(List list,
Map sortValues)
Removes items from the list which have duplicate values
|
List |
selectNodes(Object context)
|
List |
selectNodes(Object context,
XPath sortXPath)
|
List |
selectNodes(Object context,
XPath sortXPath,
boolean distinct)
|
Object |
selectObject(Object context)
selectObject evaluates an XPath expression and returns
the result as an Object . |
Node |
selectSingleNode(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(Map map)
Sets the current NamespaceContext from a Map where the keys
are the String namespace prefixes and the values are the namespace
URIs For example.
|
protected void |
setNSContext(Object context) |
void |
setVariableContext(org.jaxen.VariableContext variableContext)
Sets the variable context to be used when evaluating XPath
expressions
|
void |
sort(List list)
sort sorts the given List of Nodes
using this XPath expression as a Comparator . |
void |
sort(List list,
boolean distinct)
sort sorts the given List of Nodes
using this XPath expression as a Comparator
and optionally removing duplicates. |
protected void |
sort(List list,
Map sortValues)
Sorts the list based on the sortValues for each node
|
String |
toString() |
String |
valueOf(Object context)
valueOf evaluates this XPath expression
and returns the textual representation of the results using the
XPath string() function. |
private org.jaxen.BaseXPath xpath
private org.jaxen.NamespaceContext namespaceContext
public DefaultXPath(String text) throws InvalidXPathException
InvalidXPathException
public org.jaxen.FunctionContext getFunctionContext()
getFunctionContext
in interface XPath
public void setFunctionContext(org.jaxen.FunctionContext functionContext)
XPath
setFunctionContext
in interface XPath
public org.jaxen.NamespaceContext getNamespaceContext()
getNamespaceContext
in interface XPath
public void setNamespaceURIs(Map 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
public void setNamespaceContext(org.jaxen.NamespaceContext namespaceContext)
XPath
setNamespaceContext
in interface XPath
public org.jaxen.VariableContext getVariableContext()
getVariableContext
in interface XPath
public void setVariableContext(org.jaxen.VariableContext variableContext)
XPath
setVariableContext
in interface XPath
public Object selectObject(Object context)
XPath
public List selectNodes(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 List selectNodes(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 List selectNodes(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(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 String valueOf(Object context)
XPath
valueOf
evaluates this XPath expression
and returns the textual representation of the results using the
XPath string() function.
public Number numberValueOf(Object context)
XPath
numberValueOf
evaluates an XPath expression
and returns the numeric value of the XPath expression if the XPath
expression results in 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 void sort(List list)
sort
sorts the given List of Nodes
using this XPath expression as a Comparator
.
public void sort(List 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
protected void sort(List list, Map sortValues)
protected void removeDuplicates(List list, Map sortValues)
protected Object getCompareValue(Node node)
protected void setNSContext(Object context)
protected void handleJaxenException(org.jaxen.JaxenException e) throws XPathException
XPathException
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses