@Deprecated
public abstract class XPath
extends java.lang.Object
implements java.io.Serializable
setXPathClass(java.lang.Class<? extends org.jdom2.xpath.XPath>)
or
the system property "org.jdom2.xpath.class".限定符和类型 | 字段和说明 |
---|---|
static java.lang.String |
JDOM_OBJECT_MODEL_URI
已过时。
The string passable to the JAXP 1.3 XPathFactory isObjectModelSupported()
method to query an XPath engine regarding its support for JDOM.
|
构造器和说明 |
---|
XPath()
已过时。
|
限定符和类型 | 方法和说明 |
---|---|
abstract void |
addNamespace(Namespace namespace)
已过时。
Adds a namespace definition to the list of namespaces known of
this XPath expression.
|
void |
addNamespace(java.lang.String prefix,
java.lang.String uri)
已过时。
Adds a namespace definition (prefix and URI) to the list of
namespaces known of this XPath expression.
|
abstract java.lang.String |
getXPath()
已过时。
Returns the wrapped XPath expression as a string.
|
static XPath |
newInstance(java.lang.String path)
已过时。
Creates a new XPath wrapper object, compiling the specified
XPath expression.
|
abstract java.lang.Number |
numberValueOf(java.lang.Object context)
已过时。
Returns the number value of the first node selected by applying
the wrapped XPath expression to the given context.
|
abstract java.util.List<?> |
selectNodes(java.lang.Object context)
已过时。
Evaluates the wrapped XPath expression and returns the list
of selected items.
|
static java.util.List<?> |
selectNodes(java.lang.Object context,
java.lang.String path)
已过时。
Evaluates an XPath expression and returns the list of selected
items.
|
abstract java.lang.Object |
selectSingleNode(java.lang.Object context)
已过时。
Evaluates the wrapped XPath expression and returns the first
entry in the list of selected nodes (or atomics).
|
static java.lang.Object |
selectSingleNode(java.lang.Object context,
java.lang.String path)
已过时。
Evaluates the wrapped XPath expression and returns the first
entry in the list of selected nodes (or atomics).
|
abstract void |
setVariable(java.lang.String name,
java.lang.Object value)
已过时。
Defines an XPath variable and sets its value.
|
static void |
setXPathClass(java.lang.Class<? extends XPath> aClass)
已过时。
Sets the concrete XPath subclass to use when allocating XPath
instances.
|
abstract java.lang.String |
valueOf(java.lang.Object context)
已过时。
Returns the string value of the first node selected by applying
the wrapped XPath expression to the given context.
|
public static final java.lang.String JDOM_OBJECT_MODEL_URI
public static XPath newInstance(java.lang.String path) throws JDOMException
path
- the XPath expression to wrap.JDOMException
- if the XPath expression is invalid.public static void setXPathClass(java.lang.Class<? extends XPath> aClass) throws JDOMException
aClass
- the concrete subclass of XPath.java.lang.IllegalArgumentException
- if aClass
is
null
.JDOMException
- if aClass
is
not a concrete subclass
of XPath.public abstract java.util.List<?> selectNodes(java.lang.Object context) throws JDOMException
context
- the node to use as context for evaluating
the XPath expression.Element
,
Attribute
, Text
, CDATA
,
Comment
, ProcessingInstruction
, Boolean,
Double, or String.JDOMException
- if the evaluation of the XPath
expression on the specified context
failed.public abstract java.lang.Object selectSingleNode(java.lang.Object context) throws JDOMException
context
- the node to use as context for evaluating
the XPath expression.Element
,
Attribute
, Text
, CDATA
,
Comment
, ProcessingInstruction
, Boolean,
Double, String, or null
if no item was selected.JDOMException
- if the evaluation of the XPath
expression on the specified context
failed.public abstract java.lang.String valueOf(java.lang.Object context) throws JDOMException
context
- the element to use as context for evaluating
the XPath expression.JDOMException
- if the XPath expression is invalid or
its evaluation on the specified context
failed.public abstract java.lang.Number numberValueOf(java.lang.Object context) throws JDOMException
context
- the element to use as context for evaluating
the XPath expression.null
if no node was selected or the
special value Double.NaN
(Not-a-Number) if the selected value can not be
converted into a number value.JDOMException
- if the XPath expression is invalid or
its evaluation on the specified context
failed.public abstract void setVariable(java.lang.String name, java.lang.Object value)
name
- the variable name.value
- the variable value.java.lang.IllegalArgumentException
- if name
is not
a valid XPath variable name
or if the value type is not
supported by the underlying
implementationpublic abstract void addNamespace(Namespace namespace)
Note: In XPath, there is no such thing as a 'default namespace'. The empty prefix always resolves to the empty namespace URI.
namespace
- the namespace.public void addNamespace(java.lang.String prefix, java.lang.String uri)
Note: In XPath, there is no such thing as a 'default namespace'. The empty prefix always resolves to the empty namespace URI.
prefix
- the namespace prefix.uri
- the namespace URI.IllegalNameException
- if the prefix or uri are null or
empty strings or if they contain
illegal characters.public abstract java.lang.String getXPath()
public static java.util.List<?> selectNodes(java.lang.Object context, java.lang.String path) throws JDOMException
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 and
evaluating
it several
times is way more efficient.
context
- the node to use as context for evaluating
the XPath expression.path
- the XPath expression to evaluate.Element
,
Attribute
, Text
, CDATA
,
Comment
, ProcessingInstruction
, Boolean,
Double, or String.JDOMException
- if the XPath expression is invalid or
its evaluation on the specified context
failed.public static java.lang.Object selectSingleNode(java.lang.Object context, java.lang.String path) throws JDOMException
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 and
evaluating
it
several times is way more efficient.
context
- the element to use as context for evaluating
the XPath expression.path
- the XPath expression to evaluate.Element
,
Attribute
, Text
, CDATA
,
Comment
, ProcessingInstruction
, Boolean,
Double, String, or null
if no item was selected.JDOMException
- if the XPath expression is invalid or
its evaluation on the specified context
failed.