| java.lang.Object org.jdom.xpath.XPath
All known Subclasses: org.jdom.xpath.JaxenXPath,
XPath | abstract public class XPath implements Serializable(Code) | | A utility class for performing XPath calls on JDOM nodes, with a factory
interface for obtaining a first XPath instance. Users operate against this
class while XPath vendors can plug-in implementations underneath. Users
can choose an implementation using either
XPath.setXPathClass or
the system property "org.jdom.xpath.class".
version: $Revision: 1.2 $, $Date: 2005/05/03 07:02:04 $ author: Laurent Bihanic |
Method Summary | |
abstract public void | addNamespace(Namespace namespace) Adds a namespace definition to the list of namespaces known of
this XPath expression.
Note: In XPath, there is no such thing as a
'default namespace'. | public void | addNamespace(String prefix, String uri) Adds a namespace definition (prefix and URI) to the list of
namespaces known of this XPath expression.
Note: In XPath, there is no such thing as a
'default namespace'. | abstract public String | getXPath() Returns the wrapped XPath expression as a string. | public static XPath | newInstance(String path) Creates a new XPath wrapper object, compiling the specified
XPath expression. | abstract public Number | numberValueOf(Object context) Returns the number value of the first node selected by applying
the wrapped XPath expression to the given context.
Parameters: context - the element to use as context for evaluatingthe XPath expression. | abstract public List | selectNodes(Object context) Evaluates the wrapped XPath expression and returns the list
of selected items.
Parameters: context - the node to use as context for evaluatingthe XPath expression. | public static List | selectNodes(Object context, String path) Evaluates an XPath expression and returns the list of selected
items.
Note: This method should not be used when the
same XPath expression needs to be applied several times (on the
same or different contexts) as it requires the expression to be
compiled before being evaluated. | abstract public Object | selectSingleNode(Object context) Evaluates the wrapped XPath expression and returns the first
entry in the list of selected nodes (or atomics).
Parameters: context - the node to use as context for evaluatingthe XPath expression. | public static Object | selectSingleNode(Object context, String path) Evaluates the wrapped XPath expression and returns the first
entry in the list of selected nodes (or atomics).
Note: This method should not be used when the
same XPath expression needs to be applied several times (on the
same or different contexts) as it requires the expression to be
compiled before being evaluated. | abstract public void | setVariable(String name, Object value) Defines an XPath variable and sets its value. | public static void | setXPathClass(Class aClass) Sets the concrete XPath subclass to use when allocating XPath
instances. | abstract public String | valueOf(Object context) Returns the string value of the first node selected by applying
the wrapped XPath expression to the given context.
Parameters: context - the element to use as context for evaluatingthe XPath expression. | final protected Object | writeReplace() [Serialization support] Returns the alternative object
to write to the stream when serializing this object. |
addNamespace | abstract public void addNamespace(Namespace namespace)(Code) | | Adds a namespace definition to the list of namespaces known of
this XPath expression.
Note: In XPath, there is no such thing as a
'default namespace'. The empty prefix always resolves
to the empty namespace URI.
Parameters: namespace - the namespace. |
addNamespace | public void addNamespace(String prefix, String uri)(Code) | | Adds a namespace definition (prefix and URI) to the list of
namespaces known of this XPath expression.
Note: In XPath, there is no such thing as a
'default namespace'. The empty prefix always resolves
to the empty namespace URI.
Parameters: prefix - the namespace prefix. Parameters: uri - the namespace URI. throws: IllegalNameException - if the prefix or uri are null orempty strings or if they containillegal characters. |
getXPath | abstract public String getXPath()(Code) | | Returns the wrapped XPath expression as a string.
the wrapped XPath expression as a string. |
newInstance | public static XPath newInstance(String path) throws JDOMException(Code) | | Creates a new XPath wrapper object, compiling the specified
XPath expression.
Parameters: path - the XPath expression to wrap. throws: JDOMException - if the XPath expression is invalid. |
numberValueOf | abstract public Number numberValueOf(Object context) throws JDOMException(Code) | | Returns the number value of the first node selected by applying
the wrapped XPath expression to the given context.
Parameters: context - the element to use as context for evaluatingthe XPath expression. the number value of the first node selected by applyingthe wrapped XPath expression to the given context,null if no node was selected or thespecial value java.lang.Double.NaN(NotElement-a-Number) if the selected value can not beconverted into a number value. throws: JDOMException - if the XPath expression is invalid orits evaluation on the specified contextfailed. |
selectNodes | abstract public List selectNodes(Object context) throws JDOMException(Code) | | Evaluates the wrapped XPath expression and returns the list
of selected items.
Parameters: context - the node to use as context for evaluatingthe XPath expression. the list of selected items, which may be of types: Element,Attribute, Text, CDATA,Comment, ProcessingInstruction, Boolean,Double, or String. throws: JDOMException - if the evaluation of the XPathexpression on the specified contextfailed. |
selectNodes | public static List selectNodes(Object context, String path) throws JDOMException(Code) | | Evaluates an XPath expression and returns the list of selected
items.
Note: This method should not be used when the
same XPath expression needs to be applied several times (on the
same or different contexts) as it requires the expression to be
compiled before being evaluated. In such cases,
XPath.newInstance allocating an XPath wrapper instance and
XPath.selectNodes(java.lang.Object) evaluating it several
times is way more efficient.
Parameters: context - the node to use as context for evaluatingthe XPath expression. Parameters: path - the XPath expression to evaluate. the list of selected items, which may be of types: Element,Attribute, Text, CDATA,Comment, ProcessingInstruction, Boolean,Double, or String. throws: JDOMException - if the XPath expression is invalid orits evaluation on the specified contextfailed. |
selectSingleNode | abstract public Object selectSingleNode(Object context) throws JDOMException(Code) | | Evaluates the wrapped XPath expression and returns the first
entry in the list of selected nodes (or atomics).
Parameters: context - the node to use as context for evaluatingthe XPath expression. the first selected item, which may be of types: Element,Attribute, Text, CDATA,Comment, ProcessingInstruction, Boolean,Double, String, or null if no item was selected. throws: JDOMException - if the evaluation of the XPathexpression on the specified contextfailed. |
selectSingleNode | public static Object selectSingleNode(Object context, String path) throws JDOMException(Code) | | Evaluates the wrapped XPath expression and returns the first
entry in the list of selected nodes (or atomics).
Note: This method should not be used when the
same XPath expression needs to be applied several times (on the
same or different contexts) as it requires the expression to be
compiled before being evaluated. In such cases,
XPath.newInstance allocating an XPath wrapper instance and
XPath.selectSingleNode(java.lang.Object) evaluating it
several times is way more efficient.
Parameters: context - the element to use as context for evaluatingthe XPath expression. Parameters: path - the XPath expression to evaluate. the first selected item, which may be of types: Element,Attribute, Text, CDATA,Comment, ProcessingInstruction, Boolean,Double, String, or null if no item was selected. throws: JDOMException - if the XPath expression is invalid orits evaluation on the specified contextfailed. |
setVariable | abstract public void setVariable(String name, Object value)(Code) | | Defines an XPath variable and sets its value.
Parameters: name - the variable name. Parameters: value - the variable value. throws: IllegalArgumentException - if name is nota valid XPath variable nameor if the value type is notsupported by the underlyingimplementation |
setXPathClass | public static void setXPathClass(Class aClass) throws JDOMException(Code) | | Sets the concrete XPath subclass to use when allocating XPath
instances.
Parameters: aClass - the concrete subclass of XPath. throws: IllegalArgumentException - if aClass isnull . throws: JDOMException - if aClass isnot a concrete subclassof XPath. |
valueOf | abstract public String valueOf(Object context) throws JDOMException(Code) | | Returns the string value of the first node selected by applying
the wrapped XPath expression to the given context.
Parameters: context - the element to use as context for evaluatingthe XPath expression. the string value of the first node selected by applyingthe wrapped XPath expression to the given context. throws: JDOMException - if the XPath expression is invalid orits evaluation on the specified contextfailed. |
writeReplace | final protected Object writeReplace() throws ObjectStreamException(Code) | | [Serialization support] Returns the alternative object
to write to the stream when serializing this object. This
method returns an instance of a dedicated nested class to
serialize XPath expressions independently of the concrete
implementation being used.
Note: Subclasses are not allowed to override
this method to ensure valid serialization of all
implementations.
an XPathString instance configured with the wrappedXPath expression. throws: ObjectStreamException - never. |
|
|