Package org.apache.commons.jxpath
Interface Pointer
-
- All Superinterfaces:
java.lang.Cloneable
,java.lang.Comparable
,java.io.Serializable
- All Known Implementing Classes:
BasicTypeConverter.ValuePointer
,BeanPointer
,BeanPropertyPointer
,CollectionPointer
,ContainerPointer
,DOMAttributePointer
,DOMNodePointer
,DynaBeanPointer
,DynaBeanPropertyPointer
,DynamicPointer
,DynamicPropertyPointer
,JDOMAttributePointer
,JDOMNamespacePointer
,JDOMNodePointer
,LangAttributePointer
,NamespacePointer
,NodePointer
,NullElementPointer
,NullPointer
,NullPropertyPointer
,PropertyOwnerPointer
,PropertyPointer
,VariablePointer
public interface Pointer extends java.lang.Cloneable, java.lang.Comparable, java.io.Serializable
Pointers represent locations of objects and their properties in Java object graphs. JXPathContext has methods (getPointer()
and (iteratePointers()
, which, given an XPath, produce Pointers for the objects or properties described the the path. For example,ctx.getPointer ("foo/bar")
will produce a Pointer that can get and set the property "bar" of the object which is the value of the property "foo" of the root object. The value ofctx.getPointer("aMap/aKey[3]")
will be a pointer to the 3'rd element of the array, which is the value for the key "aKey" of the map, which is the value of the property "aMap" of the root object.- Version:
- $Revision: 652845 $ $Date: 2008-05-02 12:46:46 -0500 (Fri, 02 May 2008) $
- Author:
- Dmitri Plotnikov
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.String
asPath()
Returns a string that is a proper "canonical" XPath that corresponds to this pointer.java.lang.Object
clone()
Pointers are cloneable.java.lang.Object
getNode()
Returns the raw value of the object, property or collection element this pointer represents.java.lang.Object
getRootNode()
Returns the node this pointer is based on.java.lang.Object
getValue()
Returns the value of the object, property or collection element this pointer represents.void
setValue(java.lang.Object value)
Modifies the value of the object, property or collection element this pointer represents.
-
-
-
Method Detail
-
getValue
java.lang.Object getValue()
Returns the value of the object, property or collection element this pointer represents. May convert the value to one of the canonical InfoSet types: String, Number, Boolean, Set. For example, in the case of an XML element, getValue() will return the text contained by the element rather than the element itself.- Returns:
- Object value
-
getNode
java.lang.Object getNode()
Returns the raw value of the object, property or collection element this pointer represents. Never converts the object to a canonical type: returns it as is. For example, for an XML element, getNode() will return the element itself rather than the text it contains.- Returns:
- Object node
-
setValue
void setValue(java.lang.Object value)
Modifies the value of the object, property or collection element this pointer represents.- Parameters:
value
- value to set
-
getRootNode
java.lang.Object getRootNode()
Returns the node this pointer is based on.- Returns:
- Object
-
asPath
java.lang.String asPath()
Returns a string that is a proper "canonical" XPath that corresponds to this pointer. Consider this example:Pointer ptr = ctx.getPointer("//employees[firstName = 'John']")
The value of
ptr.asPath()
will look something like"/departments[2]/employees[3]"
, so, basically, it represents the concrete location(s) of the result of a search performed by JXPath. If an object in the pointer's path is a Dynamic Property object (like a Map), the asPath method generates an XPath that looks like this:" /departments[@name = 'HR']/employees[3]"
.- Returns:
- String path
-
clone
java.lang.Object clone()
Pointers are cloneable.- Returns:
- cloned Object
-
-