Package org.dom4j
Interface XPath
- 
- All Superinterfaces:
 NodeFilter
- All Known Implementing Classes:
 DefaultXPath
public interface XPath extends NodeFilter
XPathrepresents an XPath expression after it has been parsed from a String. 
- 
- 
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description booleanbooleanValueOf(Object context)Retrieve a boolean-value interpretation of this XPath expression when evaluated against a given context.Objectevaluate(Object context)evaluateevaluates an XPath expression and returns the result as anObject.org.jaxen.FunctionContextgetFunctionContext()DOCUMENT ME!org.jaxen.NamespaceContextgetNamespaceContext()DOCUMENT ME!StringgetText()getTextwill return the textual version of the XPath expression.org.jaxen.VariableContextgetVariableContext()DOCUMENT ME!booleanmatches(Node node)matchesreturns true if the given node matches the XPath expression.NumbernumberValueOf(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.List<Node>selectNodes(Object context)List<Node>selectNodes(Object context, XPath sortXPath)List<Node>selectNodes(Object context, XPath sortXPath, boolean distinct)ObjectselectObject(Object context)Deprecated.please use evaluate(Object) instead.NodeselectSingleNode(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.voidsetVariableContext(org.jaxen.VariableContext variableContext)Sets the variable context to be used when evaluating XPath expressionsvoidsort(List<Node> list)sortsorts the given List of Nodes using this XPath expression as aComparator.voidsort(List<Node> list, boolean distinct)sortsorts the given List of Nodes using this XPath expression as aComparatorand optionally removing duplicates.StringvalueOf(Object context)valueOfevaluates this XPath expression and returns the textual representation of the results using the XPath string() function. 
 - 
 
- 
- 
Method Detail
- 
getText
String getText()
getTextwill return the textual version of the XPath expression.- Returns:
 - the textual format of the XPath expression.
 
 
- 
matches
boolean matches(Node node)
matchesreturns 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- Parameters:
 node- DOCUMENT ME!- Returns:
 - true if the given node matches this XPath expression
 
 
- 
selectObject
Object selectObject(Object context)
Deprecated.please use evaluate(Object) instead. WILL BE REMOVED IN dom4j-1.6 !! 
- 
selectNodes
List<Node> selectNodes(Object context)
selectNodesperforms this XPath expression on the givenNodeorListofNodes instances appending all the results together into a single list.- 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
List<Node> selectNodes(Object context, XPath sortXPath)
selectNodesevaluates the XPath expression on the givenNodeorListofNodes and returns the result as aListofNodes sorted by the sort XPath expression.- 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
List<Node> selectNodes(Object context, XPath sortXPath, boolean distinct)
selectNodesevaluates the XPath expression on the givenNodeorListofNodes and returns the result as aListofNodes sorted by the sort XPath expression.- 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
Node selectSingleNode(Object context)
selectSingleNodeevaluates this XPath expression on the givenNodeorListofNodes and returns the result as a singleNodeinstance.- Parameters:
 context- is either a node or a list of nodes on which to evalute the XPath- Returns:
 - a single matching 
Nodeinstance 
 
- 
valueOf
String valueOf(Object context)
valueOfevaluates this XPath expression and returns the textual representation of the results using the XPath string() function.- Parameters:
 context- is either a node or a list of nodes on which to evalute the XPath- Returns:
 - the string representation of the results of the XPath expression
 
 
- 
numberValueOf
Number 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.- 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
boolean booleanValueOf(Object context)
Retrieve 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.- Parameters:
 context- The node, nodeset or Context object for evaluation. This value can be null- Returns:
 - The boolean-value interpretation of this expression.
 - Since:
 - 1.5
 
 
- 
sort
void sort(List<Node> list)
sortsorts the given List of Nodes using this XPath expression as aComparator.- Parameters:
 list- is the list of Nodes to sort
 
- 
sort
void sort(List<Node> list, boolean distinct)
sortsorts the given List of Nodes using this XPath expression as aComparatorand optionally removing duplicates.- Parameters:
 list- is the list of Nodes to sortdistinct- if true then duplicate values (using the sortXPath for comparisions) will be removed from the List
 
- 
getFunctionContext
org.jaxen.FunctionContext getFunctionContext()
DOCUMENT ME!- Returns:
 - the current function context
 
 
- 
setFunctionContext
void setFunctionContext(org.jaxen.FunctionContext functionContext)
Sets the function context to be used when evaluating XPath expressions- Parameters:
 functionContext- DOCUMENT ME!
 
- 
getNamespaceContext
org.jaxen.NamespaceContext getNamespaceContext()
DOCUMENT ME!- Returns:
 - the current namespace context
 
 
- 
setNamespaceContext
void setNamespaceContext(org.jaxen.NamespaceContext namespaceContext)
Sets the namespace context to be used when evaluating XPath expressions- Parameters:
 namespaceContext- DOCUMENT ME!
 
- 
setNamespaceURIs
void setNamespaceURIs(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. 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);- Parameters:
 map- the map containing the namespace mappings
 
- 
getVariableContext
org.jaxen.VariableContext getVariableContext()
DOCUMENT ME!- Returns:
 - the current variable context
 
 
- 
setVariableContext
void setVariableContext(org.jaxen.VariableContext variableContext)
Sets the variable context to be used when evaluating XPath expressions- Parameters:
 variableContext- DOCUMENT ME!
 
 - 
 
 -