|
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
org.dom4j.xpath Class DefaultXPath
java.lang.Objectorg.dom4j.xpath.DefaultXPath
- All Implemented Interfaces:
- NodeFilter, Serializable, XPath
- public class DefaultXPath
- extends Object
- implements XPath, NodeFilter, Serializable
Default implementation of XPathwhich uses the Jaxen project.
- Author:
- bob mcwhirter, James Strachan
- See Also:
- Serialized Form
| Constructor Summary | |
DefaultXPath(String text)
Construct an XPath |
|
| Method Summary | |
boolean |
booleanValueOf(Object context)
Retrieve a boolean-value interpretation of this XPath expression when evaluated against a given context. |
Object |
evaluate(Object context)
evaluate evaluates an XPath expression and returns the
result as an Object. |
protected Object |
getCompareValue(Node node)
DOCUMENT ME! |
org.jaxen.FunctionContext |
getFunctionContext()
DOCUMENT ME! |
org.jaxen.NamespaceContext |
getNamespaceContext()
DOCUMENT ME! |
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. |
Number |
numberValueOf(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(String text)
|
protected void |
removeDuplicates(List list,
Map sortValues)
Removes items from the list which have duplicate values |
List |
selectNodes(Object context)
selectNodes performs this XPath expression on the given
Nodeor Listof Nodes instances appending all
the results together into a single list.
|
List |
selectNodes(Object context,
XPath sortXPath)
selectNodes evaluates the XPath expression on the given
Nodeor Listof Nodes and returns the result as
a List of Node s sorted by the sort XPath
expression.
|
List |
selectNodes(Object context,
XPath sortXPath,
boolean distinct)
selectNodes evaluates the XPath expression on the given
Nodeor Listof Nodes and returns the result as
a List of Node s sorted by the sort XPath
expression.
|
Object |
selectObject(Object context)
selectObject evaluates an XPath expression and returns the
result as an Object. |
Node |
selectSingleNode(Object context)
selectSingleNode evaluates this XPath expression on the
given Nodeor Listof Nodes and returns the
result as a single Node instance.
|
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. |
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 Comparatorand 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.
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
DefaultXPath
public DefaultXPath(String text) throws InvalidXPathException
- Construct an XPath
- Parameters:
text- DOCUMENT ME!- Throws:
InvalidXPathException- DOCUMENT ME!
| Method Detail |
toString
public String toString()
getText
public String getText()
- Retrieve the textual XPath string used to initialize this Object
- Returns:
- The XPath string
getFunctionContext
public org.jaxen.FunctionContext getFunctionContext()
- Description copied from interface:
XPath - DOCUMENT ME!
- Specified by:
getFunctionContextin interfaceXPath
- Returns:
- the current function context
setFunctionContext
public void setFunctionContext(org.jaxen.FunctionContext functionContext)
- Description copied from interface:
XPath - Sets 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:
XPath - DOCUMENT ME!
- Specified by:
getNamespaceContextin interfaceXPath
- Returns:
- the current namespace context
setNamespaceURIs
public void setNamespaceURIs(Map map)
- Description copied from interface:
XPath 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);- Specified by:
setNamespaceURIsin interfaceXPath
- Parameters:
map- the map containing the namespace mappings
setNamespaceContext
public void setNamespaceContext(org.jaxen.NamespaceContext namespaceContext)
- Description copied from interface:
XPath - Sets 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:
XPath - DOCUMENT ME!
- Specified by:
getVariableContextin interfaceXPath
- Returns:
- the current variable context
setVariableContext
public void setVariableContext(org.jaxen.VariableContext variableContext)
- Description copied from interface:
XPath - Sets the variable context to be used when evaluating XPath expressions
- Specified by:
setVariableContextin interfaceXPath
- Parameters:
variableContext- DOCUMENT ME!
evaluate
public Object evaluate(Object context)
- Description copied from interface:
XPath evaluateevaluates an XPath expression and returns the result as anObject. The object returned can either be aListofNodeinstances, aNodeinstance, aStringor aNumberinstance depending on the XPath expression.
selectObject
public Object selectObject(Object context)
- Description copied from interface:
XPath selectObjectevaluates an XPath expression and returns the result as anObject. The object returned can either be aListofNodeinstances, aNodeinstance, aStringor aNumberinstance depending on the XPath expression.- Specified by:
selectObjectin interfaceXPath
selectNodes
public List selectNodes(Object context)
- Description copied from interface:
XPath selectNodesperforms 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
public List selectNodes(Object context, XPath sortXPath)
- Description copied from interface:
XPath selectNodesevaluates 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
public List selectNodes(Object context, XPath sortXPath, boolean distinct)
- Description copied from interface:
XPath selectNodesevaluates 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
public Node selectSingleNode(Object context)
- Description copied from interface:
XPath selectSingleNodeevaluates 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
public String valueOf(Object context)
- Description copied from interface:
XPath 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
public Number numberValueOf(Object context)
- Description copied from interface:
XPath 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.- 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
public boolean booleanValueOf(Object context)
- Description copied from interface:
XPath - Retrieve a boolean-value interpretation of this XPath expression when
evaluated against a given context.
The boolean-value of the expression is determined per the
boolean(..)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
public void sort(List list)
sortsorts the given List of Nodes using this XPath expression as aComparator.- Parameters:
list- is the list of Nodes to sort
sort
public void sort(List 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
matches
public boolean matches(Node node)
- Description copied from interface:
XPath 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.- Parameters:
node- DOCUMENT ME!- Returns:
- true if the given node matches this XPath expression
sort
protected void sort(List list, Map sortValues)
- Sorts the list based on the sortValues for each node
- Parameters:
list- DOCUMENT ME!sortValues- DOCUMENT ME!
removeDuplicates
protected void removeDuplicates(List list, Map sortValues)
- Removes items from the list which have duplicate values
- Parameters:
list- DOCUMENT ME!sortValues- DOCUMENT ME!
getCompareValue
protected Object getCompareValue(Node node)
- DOCUMENT ME!
- Parameters:
node- DOCUMENT ME!- Returns:
- the node expression used for sorting comparisons
parse
protected static org.jaxen.XPath parse(String text)
setNSContext
protected void setNSContext(Object context)
handleJaxenException
protected void handleJaxenException(org.jaxen.JaxenException exception)
throws XPathException
- Throws:
XPathException
|
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
Copyright © 2001-2005 MetaStuff Ltd.. All Rights Reserved.
org.dom4j.xpath.DefaultXPath