|
|||||||||
| Home >> All >> org >> jdom >> [ xpath overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.jdom.xpath
Class XPath

java.lang.Objectorg.jdom.xpath.XPath
- All Implemented Interfaces:
- java.io.Serializable
- Direct Known Subclasses:
- JaxenXPath
- public abstract class XPath
- extends java.lang.Object
- implements java.io.Serializable
- extends java.lang.Object
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 setXPathClass(java.lang.Class) 55 or
the system property "org.jdom.xpath.class".
- Version:
- $Revision: 1.15 $, $Date: 2004/02/06 09:28:32 $
| Nested Class Summary | |
private static class |
XPath.XPathString
The XPathString is dedicated to serialize instances of XPath subclasses in a implementation-independent manner. |
| Field Summary | |
private static java.lang.reflect.Constructor |
constructor
The constructor to instanciate a new XPath concrete implementation. |
private static java.lang.String |
CVS_ID
|
private static java.lang.String |
DEFAULT_XPATH_CLASS
The default implementation class to use if none was configured. |
private static java.lang.String |
XPATH_CLASS_PROPERTY
The name of the system property from which to retrieve the name of the implementation class to use. |
| Constructor Summary | |
XPath()
|
|
| Method Summary | |
abstract void |
addNamespace(org.jdom.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 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. |
protected java.lang.Object |
writeReplace()
[Serialization support] Returns the alternative object to write to the stream when serializing this object. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
CVS_ID
private static final java.lang.String CVS_ID
- See Also:
- Constant Field Values
XPATH_CLASS_PROPERTY
private static final java.lang.String XPATH_CLASS_PROPERTY
- The name of the system property from which to retrieve the
name of the implementation class to use.
The property name is: "
org.jdom.xpath.class".- See Also:
- Constant Field Values
DEFAULT_XPATH_CLASS
private static final java.lang.String DEFAULT_XPATH_CLASS
- The default implementation class to use if none was configured.
- See Also:
- Constant Field Values
constructor
private static java.lang.reflect.Constructor constructor
- The constructor to instanciate a new XPath concrete
implementation.
- See Also:
newInstance(java.lang.String)55
| Constructor Detail |
XPath
public XPath()
| Method Detail |
newInstance
public static XPath newInstance(java.lang.String path) throws org.jdom.JDOMException
- Creates a new XPath wrapper object, compiling the specified
XPath expression.
setXPathClass
public static void setXPathClass(java.lang.Class aClass) throws org.jdom.JDOMException
- Sets the concrete XPath subclass to use when allocating XPath
instances.
selectNodes
public abstract java.util.List selectNodes(java.lang.Object context) throws org.jdom.JDOMException
- Evaluates the wrapped XPath expression and returns the list
of selected items.
selectSingleNode
public abstract java.lang.Object selectSingleNode(java.lang.Object context) throws org.jdom.JDOMException
- Evaluates the wrapped XPath expression and returns the first
entry in the list of selected nodes (or atomics).
valueOf
public abstract java.lang.String valueOf(java.lang.Object context) throws org.jdom.JDOMException
- Returns the string value of the first node selected by applying
the wrapped XPath expression to the given context.
numberValueOf
public abstract java.lang.Number numberValueOf(java.lang.Object context) throws org.jdom.JDOMException
- Returns the number value of the first node selected by applying
the wrapped XPath expression to the given context.
setVariable
public abstract void setVariable(java.lang.String name, java.lang.Object value)
- Defines an XPath variable and sets its value.
addNamespace
public abstract void addNamespace(org.jdom.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'. The empty prefix always resolves to the empty namespace URI.
addNamespace
public 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.
Note: In XPath, there is no such thing as a 'default namespace'. The empty prefix always resolves to the empty namespace URI.
getXPath
public abstract java.lang.String getXPath()
- Returns the wrapped XPath expression as a string.
selectNodes
public static java.util.List selectNodes(java.lang.Object context, java.lang.String path) throws org.jdom.JDOMException
- 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 55 an XPath wrapper instance and evaluating 55 it several times is way more efficient.
selectSingleNode
public static java.lang.Object selectSingleNode(java.lang.Object context, java.lang.String path) throws org.jdom.JDOMException
- 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 55 an XPath wrapper instance and evaluating 55 it several times is way more efficient.
writeReplace
protected final java.lang.Object writeReplace() throws java.io.ObjectStreamException
- [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.
|
|||||||||
| Home >> All >> org >> jdom >> [ xpath overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.jdom.xpath.XPath