Class DefaultXPath
java.lang.Object
org.dom4j.xpath.DefaultXPath
- All Implemented Interfaces:
Serializable, NodeFilter, XPath
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.jaxen.NamespaceContextprivate Stringprivate org.jaxen.XPath -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanValueOf(Object context) Retrieve a boolean-value interpretation of this XPath expression when evaluated against a given context.evaluateevaluates an XPath expression and returns the result as anObject.protected ObjectgetCompareValue(Node node) DOCUMENT ME!org.jaxen.FunctionContextDOCUMENT ME!org.jaxen.NamespaceContextDOCUMENT ME!getText()Retrieve the textual XPath string used to initialize this Objectorg.jaxen.VariableContextDOCUMENT ME!protected voidhandleJaxenException(org.jaxen.JaxenException exception) booleanmatchesreturns true if the given node matches the XPath expression.numberValueOf(Object context) numberValueOfevaluates 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.XPathprotected voidRemoves items from the list which have duplicate valuesselectNodes(Object context) selectNodes(Object context, XPath sortXPath) selectNodes(Object context, XPath sortXPath, boolean distinct) selectObject(Object context) selectObjectevaluates an XPath expression and returns the result as anObject.selectSingleNode(Object context) voidsetFunctionContext(org.jaxen.FunctionContext functionContext) Sets the function context to be used when evaluating XPath expressionsvoidsetNamespaceContext(org.jaxen.NamespaceContext namespaceContext) Sets the namespace context to be used when evaluating XPath expressionsvoidsetNamespaceURIs(Map<String, 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 voidsetNSContext(Object context) voidsetVariableContext(org.jaxen.VariableContext variableContext) Sets the variable context to be used when evaluating XPath expressionsvoidsortsorts the given List of Nodes using this XPath expression as aComparator.voidsortsorts the given List of Nodes using this XPath expression as aComparatorand optionally removing duplicates.protected voidSorts the list based on the sortValues for each nodetoString()valueOfevaluates this XPath expression and returns the textual representation of the results using the XPath string() function.
-
Field Details
-
text
-
xpath
private org.jaxen.XPath xpath -
namespaceContext
private org.jaxen.NamespaceContext namespaceContext
-
-
Constructor Details
-
DefaultXPath
Construct an XPath- Parameters:
text- DOCUMENT ME!- Throws:
InvalidXPathException- DOCUMENT ME!
-
-
Method Details
-
toString
-
getText
-
getFunctionContext
public org.jaxen.FunctionContext getFunctionContext()Description copied from interface:XPathDOCUMENT ME!- Specified by:
getFunctionContextin interfaceXPath- Returns:
- the current function context
-
setFunctionContext
public void setFunctionContext(org.jaxen.FunctionContext functionContext) Description copied from interface:XPathSets the function context to be used when evaluating XPath expressions- Specified by:
setFunctionContextin interfaceXPath- Parameters:
functionContext- DOCUMENT ME!
-
getNamespaceContext
public org.jaxen.NamespaceContext getNamespaceContext()Description copied from interface:XPathDOCUMENT ME!- Specified by:
getNamespaceContextin interfaceXPath- Returns:
- the current namespace context
-
setNamespaceURIs
Description copied from interface:XPathSets the current NamespaceContext from a Map where the keys are the String namespace prefixes and the values are the namespace URIs. For example: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);- Specified by:
setNamespaceURIsin interfaceXPath- Parameters:
map- the map containing the namespace mappings
-
setNamespaceContext
public void setNamespaceContext(org.jaxen.NamespaceContext namespaceContext) Description copied from interface:XPathSets the namespace context to be used when evaluating XPath expressions- Specified by:
setNamespaceContextin interfaceXPath- Parameters:
namespaceContext- DOCUMENT ME!
-
getVariableContext
public org.jaxen.VariableContext getVariableContext()Description copied from interface:XPathDOCUMENT ME!- Specified by:
getVariableContextin interfaceXPath- Returns:
- the current variable context
-
setVariableContext
public void setVariableContext(org.jaxen.VariableContext variableContext) Description copied from interface:XPathSets the variable context to be used when evaluating XPath expressions- Specified by:
setVariableContextin interfaceXPath- Parameters:
variableContext- DOCUMENT ME!
-
evaluate
-
selectObject
-
selectNodes
Description copied from interface:XPathselectNodesperforms this XPath expression on the givenNodeorListofNodes instances appending all the results together into a single list.- Specified by:
selectNodesin interfaceXPath- Parameters:
context- is either a node or a list of nodes on which to evalute the XPath- Returns:
- the results of all the XPath evaluations as a single list
-
selectNodes
Description copied from interface:XPathselectNodesevaluates the XPath expression on the givenNodeorListofNodes and returns the result as aListofNodes sorted by the sort XPath expression.- Specified by:
selectNodesin interfaceXPath- Parameters:
context- is either a node or a list of nodes on which to evalute the XPathsortXPath- is the XPath expression to sort by- Returns:
- a list of
Nodeinstances
-
selectNodes
Description copied from interface:XPathselectNodesevaluates the XPath expression on the givenNodeorListofNodes and returns the result as aListofNodes sorted by the sort XPath expression.- Specified by:
selectNodesin interfaceXPath- Parameters:
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 result- Returns:
- a list of
Nodeinstances
-
selectSingleNode
Description copied from interface:XPathselectSingleNodeevaluates this XPath expression on the givenNodeorListofNodes and returns the result as a singleNodeinstance.- Specified by:
selectSingleNodein interfaceXPath- Parameters:
context- is either a node or a list of nodes on which to evalute the XPath- Returns:
- a single matching
Nodeinstance
-
valueOf
Description copied from interface:XPathvalueOfevaluates this XPath expression and returns the textual representation of the results using the XPath string() function. -
numberValueOf
Description copied from interface:XPathnumberValueOfevaluates 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.- Specified by:
numberValueOfin interfaceXPath- Parameters:
context- is either a node or a list of nodes on which to evalute the XPath- Returns:
- the numeric result of the XPath expression or null if the result is not a number.
-
booleanValueOf
Description copied from interface:XPathRetrieve a boolean-value interpretation of this XPath expression when evaluated against a given context. The boolean-value of the expression is determined per theboolean(..)core function as defined in the XPath specification. This means that an expression that selects zero nodes will returnfalse, while an expression that selects one-or-more nodes will returntrue.- Specified by:
booleanValueOfin interfaceXPath- Parameters:
context- The node, nodeset or Context object for evaluation. This value can be null- Returns:
- The boolean-value interpretation of this expression.
-
sort
sortsorts the given List of Nodes using this XPath expression as aComparator. -
sort
sortsorts the given List of Nodes using this XPath expression as aComparatorand optionally removing duplicates. -
matches
Description copied from interface:XPathmatchesreturns 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.- Specified by:
matchesin interfaceNodeFilter- Specified by:
matchesin interfaceXPath- Parameters:
node- DOCUMENT ME!- Returns:
- true if the given node matches this XPath expression
-
sort
-
removeDuplicates
-
getCompareValue
-
parse
-
setNSContext
-
handleJaxenException
- Throws:
XPathException
-