Top Description Fields Constructors Methods
org.jdom2.xpath.jaxen

public Class JDOMXPath

extends XPath
Class Inheritance
Annotations
@Deprecated
Imports
java.util.ArrayList, .Iterator, .List, org.jaxen.BaseXPath, .JaxenException, .SimpleVariableContext, .XPath, org.jdom2.Attribute, .CDATA, .Comment, .Element, .JDOMException, .Namespace, .ProcessingInstruction, .Text

Deprecated

replaced by compiled version.

A concrete XPath implementation for Jaxen. This class must be public because the main JDOM XPath class needs to access the class, and the constructor. The generic type of the returned values from this XPath instance.
Author
Laurent Bihanic

Field Summary

Modifier and TypeField and Description
private static final long
private transient XPath
xPath

The compiled XPath object to select nodes.

Inherited from org.jdom2.xpath.XPath:
JDOM_OBJECT_MODEL_URI

Constructor Summary

AccessConstructor and Description
public
JDOMXPath(String
the XPath expression to wrap.
expr
)

Creates a new XPath wrapper object, compiling the specified XPath expression.

Method Summary

Modifier and TypeMethod and Description
public void
addNamespace(Namespace
the namespace.
namespace
)

Implements abstract org.jdom2.xpath.XPath.addNamespace.

Adds a namespace definition to the list of namespaces known of this XPath expression.
public String

Returns:

the wrapped XPath expression as a string.
getXPath
()

Implements abstract org.jdom2.xpath.XPath.getXPath.

Returns the wrapped XPath expression as a string.
public Number

Returns:

the number value of the first item selected by applying the wrapped XPath expression to the given context, null if no node was selected or the special value java.lang.Double#NaN (Not-a-Number) if the selected value can not be converted into a number value.
numberValueOf
(Object
the element to use as context for evaluating the XPath expression.
context
)

Implements abstract org.jdom2.xpath.XPath.numberValueOf.

Returns the number value of the first item selected by applying the wrapped XPath expression to the given context.
public List<?>

Returns:

the list of selected items, which may be of types: Element , Attribute, Text, CDATA, Comment , ProcessingInstruction, Boolean, Double, or String.
selectNodes
(Object
the node to use as context for evaluating the XPath expression.
context
)

Implements abstract org.jdom2.xpath.XPath.selectNodes.

Evaluates the wrapped XPath expression and returns the list of selected items.
public Object

Returns:

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.
selectSingleNode
(Object
the node to use as context for evaluating the XPath expression.
context
)

Implements abstract org.jdom2.xpath.XPath.selectSingleNode.

Evaluates the wrapped XPath expression and returns the first entry in the list of selected nodes (or atomics).
public void
setVariable(String
the variable name.
name
,
Object
the variable value.
value
)

Implements abstract org.jdom2.xpath.XPath.setVariable.

Defines an XPath variable and sets its value.
private void
setXPath(String
the XPath expression to wrap.
expr
)

Compiles and sets the XPath expression wrapped by this object.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
private static final List<Object>

Returns:

The parameter list with NamespaceContainer instances replaced by the wrapped Namespace instances.
unWrap
(List<?>
A list potentially containing NamespaceContainer instances
results
)

Same story, need to be able to replace NamespaceContainer instances with Namespace content.

private static final Object

Returns:

The input parameter unless it is a NamespaceContainer in which case return the wrapped Namespace
unWrapNS
(Object
A result object which could potentially be a NamespaceContainer
o
)

Same story, need to be able to strip NamespaceContainer instances from Namespace content.

public String

Returns:

the string value of the first node selected by applying the wrapped XPath expression to the given context.
valueOf
(Object
the element to use as context for evaluating the XPath expression.
context
)

Implements abstract org.jdom2.xpath.XPath.valueOf.

Returns the string value of the first node selected by applying the wrapped XPath expression to the given context.
Inherited from org.jdom2.xpath.XPath:
addNamespacenewInstanceselectNodesselectSingleNodesetXPathClasswriteReplace

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.jdom2.xpath.XPath.serialVersionUID.

Default mechanism. The serialization for this class is broken. It is only included here for compatibility with JDOM 1.x

xPathback to summary
private transient XPath xPath

The compiled XPath object to select nodes. This attribute cannot be made final as it needs to be set upon object deserialization.

Constructor Detail

JDOMXPathback to summary
public JDOMXPath(String expr) throws JDOMException

Creates a new XPath wrapper object, compiling the specified XPath expression.

Parameters
expr:String

the XPath expression to wrap.

Exceptions
JDOMException:
if the XPath expression is invalid.

Method Detail

addNamespaceback to summary
public void addNamespace(Namespace namespace)

Implements abstract org.jdom2.xpath.XPath.addNamespace.

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:Namespace

the namespace.

Annotations
@Override
getXPathback to summary
public String getXPath()

Implements abstract org.jdom2.xpath.XPath.getXPath.

Returns the wrapped XPath expression as a string.

Returns:String

the wrapped XPath expression as a string.

Annotations
@Override
numberValueOfback to summary
public Number numberValueOf(Object context) throws JDOMException

Implements abstract org.jdom2.xpath.XPath.numberValueOf.

Returns the number value of the first item selected by applying the wrapped XPath expression to the given context.

Parameters
context:Object

the element to use as context for evaluating the XPath expression.

Returns:Number

the number value of the first item selected by applying the wrapped XPath expression to the given context, null if no node was selected or the special value java.lang.Double#NaN (Not-a-Number) if the selected value can not be converted into a number value.

Annotations
@Override
Exceptions
JDOMException:
if the XPath expression is invalid or its evaluation on the specified context failed.
selectNodesback to summary
public List<?> selectNodes(Object context) throws JDOMException

Implements abstract org.jdom2.xpath.XPath.selectNodes.

Evaluates the wrapped XPath expression and returns the list of selected items.

Parameters
context:Object

the node to use as context for evaluating the XPath expression.

Returns:List<?>

the list of selected items, which may be of types: Element , Attribute, Text, CDATA, Comment , ProcessingInstruction, Boolean, Double, or String.

Annotations
@Override
Exceptions
JDOMException:
if the evaluation of the XPath expression on the specified context failed.
selectSingleNodeback to summary
public Object selectSingleNode(Object context) throws JDOMException

Implements abstract org.jdom2.xpath.XPath.selectSingleNode.

Evaluates the wrapped XPath expression and returns the first entry in the list of selected nodes (or atomics).

Parameters
context:Object

the node to use as context for evaluating the XPath expression.

Returns:Object

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.

Annotations
@Override
Exceptions
JDOMException:
if the evaluation of the XPath expression on the specified context failed.
setVariableback to summary
public void setVariable(String name, Object value) throws IllegalArgumentException

Implements abstract org.jdom2.xpath.XPath.setVariable.

Defines an XPath variable and sets its value.

Parameters
name:String

the variable name.

value:Object

the variable value.

Annotations
@Override
Exceptions
IllegalArgumentException:
if name is not a valid XPath variable name or if the value type is not supported by the underlying implementation
setXPathback to summary
private void setXPath(String expr) throws JDOMException

Compiles and sets the XPath expression wrapped by this object.

Parameters
expr:String

the XPath expression to wrap.

Exceptions
JDOMException:
if the XPath expression is invalid.
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
unWrapback to summary
private static final List<Object> unWrap(List<?> results)

Same story, need to be able to replace NamespaceContainer instances with Namespace content.

Parameters
results:List<?>

A list potentially containing NamespaceContainer instances

Returns:List<Object>

The parameter list with NamespaceContainer instances replaced by the wrapped Namespace instances.

unWrapNSback to summary
private static final Object unWrapNS(Object o)

Same story, need to be able to strip NamespaceContainer instances from Namespace content.

Parameters
o:Object

A result object which could potentially be a NamespaceContainer

Returns:Object

The input parameter unless it is a NamespaceContainer in which case return the wrapped Namespace

valueOfback to summary
public String valueOf(Object context) throws JDOMException

Implements abstract org.jdom2.xpath.XPath.valueOf.

Returns the string value of the first node selected by applying the wrapped XPath expression to the given context.

Parameters
context:Object

the element to use as context for evaluating the XPath expression.

Returns:String

the string value of the first node selected by applying the wrapped XPath expression to the given context.

Annotations
@Override
Exceptions
JDOMException:
if the XPath expression is invalid or its evaluation on the specified context failed.