Class XPath
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
JDOMXPath
setXPathClass(java.lang.Class<? extends org.jdom2.xpath.XPath>)
or
the system property "org.jdom2.xpath.class".- Author:
- Laurent Bihanic
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Deprecated.The string passable to the JAXP 1.3 XPathFactory isObjectModelSupported() method to query an XPath engine regarding its support for JDOM. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addNamespace
(String prefix, String uri) Deprecated.Adds a namespace definition (prefix and URI) to the list of namespaces known of this XPath expression.abstract void
addNamespace
(Namespace namespace) Deprecated.Adds a namespace definition to the list of namespaces known of this XPath expression.abstract String
getXPath()
Deprecated.Returns the wrapped XPath expression as a string.static XPath
newInstance
(String path) Deprecated.Creates a new XPath wrapper object, compiling the specified XPath expression.abstract Number
numberValueOf
(Object context) Deprecated.Returns the number value of the first node selected by applying the wrapped XPath expression to the given context.abstract List<?>
selectNodes
(Object context) Deprecated.Evaluates the wrapped XPath expression and returns the list of selected items.static List<?>
selectNodes
(Object context, String path) Deprecated.Evaluates an XPath expression and returns the list of selected items.abstract Object
selectSingleNode
(Object context) Deprecated.Evaluates the wrapped XPath expression and returns the first entry in the list of selected nodes (or atomics).static Object
selectSingleNode
(Object context, String path) Deprecated.Evaluates the wrapped XPath expression and returns the first entry in the list of selected nodes (or atomics).abstract void
setVariable
(String name, Object value) Deprecated.Defines an XPath variable and sets its value.static void
setXPathClass
(Class<? extends XPath> aClass) Deprecated.Sets the concrete XPath subclass to use when allocating XPath instances.abstract String
Deprecated.Returns the string value of the first node selected by applying the wrapped XPath expression to the given context.protected final Object
Deprecated.[Serialization support] Returns the alternative object to write to the stream when serializing this object.
-
Field Details
-
JDOM_OBJECT_MODEL_URI
Deprecated.The string passable to the JAXP 1.3 XPathFactory isObjectModelSupported() method to query an XPath engine regarding its support for JDOM. Defined to be the well-known URI "http://jdom.org/jaxp/xpath/jdom".- See Also:
-
-
Constructor Details
-
XPath
public XPath()Deprecated.
-
-
Method Details
-
newInstance
Deprecated.Creates a new XPath wrapper object, compiling the specified XPath expression.- Parameters:
path
- the XPath expression to wrap.- Returns:
- an XPath instance representing the input path
- Throws:
JDOMException
- if the XPath expression is invalid.
-
setXPathClass
Deprecated.Sets the concrete XPath subclass to use when allocating XPath instances.- Parameters:
aClass
- the concrete subclass of XPath.- Throws:
IllegalArgumentException
- ifaClass
isnull
.JDOMException
- ifaClass
is not a concrete subclass of XPath.
-
selectNodes
Deprecated.Evaluates the wrapped XPath expression and returns the list of selected items.- Parameters:
context
- the node to use as context for evaluating the XPath expression.- Returns:
- 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 XPath expression on the specified context failed.
-
selectSingleNode
Deprecated.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 evaluating the XPath expression.- Returns:
- the first selected item, which may be of types:
Element
,Attribute
,Text
,CDATA
,Comment
,ProcessingInstruction
, Boolean, Double, String, ornull
if no item was selected. - Throws:
JDOMException
- if the evaluation of the XPath expression on the specified context failed.
-
valueOf
Deprecated.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 evaluating the XPath expression.- Returns:
- the string value of the first node selected by applying the wrapped XPath expression to the given context.
- Throws:
JDOMException
- if the XPath expression is invalid or its evaluation on the specified context failed.
-
numberValueOf
Deprecated.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 evaluating the XPath expression.- Returns:
- the number value of the first node selected by applying
the wrapped XPath expression to the given context,
null
if no node was selected or the special valueDouble.NaN
(Not-a-Number) if the selected value can not be converted into a number value. - Throws:
JDOMException
- if the XPath expression is invalid or its evaluation on the specified context failed.
-
setVariable
Deprecated.Defines an XPath variable and sets its value.- Parameters:
name
- the variable name.value
- the variable value.- Throws:
IllegalArgumentException
- ifname
is not a valid XPath variable name or if the value type is not supported by the underlying implementation
-
addNamespace
Deprecated.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
Deprecated.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.uri
- the namespace URI.- Throws:
IllegalNameException
- if the prefix or uri are null or empty strings or if they contain illegal characters.
-
getXPath
Deprecated.Returns the wrapped XPath expression as a string.- Returns:
- the wrapped XPath expression as a string.
-
selectNodes
Deprecated.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,
allocating
an XPath wrapper instance andevaluating
it several times is way more efficient.- Parameters:
context
- the node to use as context for evaluating the XPath expression.path
- the XPath expression to evaluate.- Returns:
- 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 or its evaluation on the specified context failed.
-
selectSingleNode
Deprecated.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,
allocating
an XPath wrapper instance andevaluating
it several times is way more efficient.- Parameters:
context
- the element to use as context for evaluating the XPath expression.path
- the XPath expression to evaluate.- Returns:
- the first selected item, which may be of types:
Element
,Attribute
,Text
,CDATA
,Comment
,ProcessingInstruction
, Boolean, Double, String, ornull
if no item was selected. - Throws:
JDOMException
- if the XPath expression is invalid or its evaluation on the specified context failed.
-
writeReplace
Deprecated.[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.
- Returns:
- an XPathString instance configured with the wrapped XPath expression.
- Throws:
ObjectStreamException
- never.
-