Top Description Inners Fields Constructors Methods
org.jdom.xpath

pack-priv Class JaxenXPath

extends XPath
Class Inheritance
Imports
java.util.*, org.jaxen.*, org.jaxen.jdom.*, org.jdom.*

A non-public concrete XPath implementation for Jaxen.
Author
Laurent Bihanic
Version
$Revision: 1.20 $, $Date: 2007/11/10 05:29:02 $

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private Object
currentContext

The current context for XPath expression evaluation.

private static final String
private transient JDOMXPath
xPath

The compiled XPath object to select nodes.

Inherited from org.jdom.xpath.XPath:
JDOM_OBJECT_MODEL_URI

Constructor Summary

AccessConstructor and Description
public
JaxenXPath(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.jdom.xpath.XPath.addNamespace.

Adds a namespace definition to the list of namespaces known of this XPath expression.
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public String

Returns:

the wrapped XPath expression as a string.
getXPath
()

Implements abstract org.jdom.xpath.XPath.getXPath.

Returns the wrapped XPath expression as a string.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
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.jdom.xpath.XPath.numberValueOf.

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

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.jdom.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.jdom.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.jdom.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.
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.jdom.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.jdom.xpath.XPath:
addNamespacenewInstanceselectNodesselectSingleNodesetXPathClasswriteReplace

Field Detail

currentContextback to summary
private Object currentContext

The current context for XPath expression evaluation.

CVS_IDback to summary
private static final String CVS_ID

Hides org.jdom.xpath.XPath.CVS_ID.

xPathback to summary
private transient JDOMXPath xPath

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

Constructor Detail

JaxenXPathback to summary
public JaxenXPath(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.jdom.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.

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

getXPathback to summary
public String getXPath()

Implements abstract org.jdom.xpath.XPath.getXPath.

Returns the wrapped XPath expression as a string.

Returns:String

the wrapped XPath expression as a string.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

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

Implements abstract org.jdom.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.

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

Implements abstract org.jdom.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<E>

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

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.jdom.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.

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.jdom.xpath.XPath.setVariable.

Defines an XPath variable and sets its value.

Parameters
name:String

the variable name.

value:Object

the variable value.

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.

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

Implements abstract org.jdom.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.

Exceptions
JDOMException:
if the XPath expression is invalid or its evaluation on the specified context failed.
org.jdom.xpath back to summary

private Class JaxenXPath.NSContext

extends SimpleNamespaceContext
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the namespace URI matching the prefix.
translateNamespacePrefixToUri
(String
the namespace prefix to resolve.
prefix
)

Overrides org.jaxen.SimpleNamespaceContext.translateNamespacePrefixToUri.

Implements org.jaxen.NamespaceContext.translateNamespacePrefixToUri.

[Jaxen NamespaceContext interface support] Translates the provided namespace prefix into the matching bound namespace URI.
Inherited from org.jaxen.SimpleNamespaceContext:
addElementNamespacesaddNamespace

Constructor Detail

NSContextback to summary
public NSContext()

Method Detail

translateNamespacePrefixToUriback to summary
public String translateNamespacePrefixToUri(String prefix)

Overrides org.jaxen.SimpleNamespaceContext.translateNamespacePrefixToUri.

Implements org.jaxen.NamespaceContext.translateNamespacePrefixToUri.

[Jaxen NamespaceContext interface support] Translates the provided namespace prefix into the matching bound namespace URI.

Parameters
prefix:String

the namespace prefix to resolve.

Returns:String

the namespace URI matching the prefix.