public interface Pointer extends Cloneable, Comparable, Serializable
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 of ctx.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.Modifier and Type | Method and Description |
---|---|
String |
asPath()
Returns a string that is a proper "canonical" XPath that corresponds to
this pointer.
|
Object |
clone()
Pointers are cloneable.
|
Object |
getNode()
Returns the raw value of the object, property or collection element
this pointer represents.
|
Object |
getRootNode()
Returns the node this pointer is based on.
|
Object |
getValue()
Returns the value of the object, property or collection element
this pointer represents.
|
void |
setValue(Object value)
Modifies the value of the object, property or collection element
this pointer represents.
|
compareTo
Object getValue()
Object getNode()
void setValue(Object value)
value
- value to setObject getRootNode()
String asPath()
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]"
.
Copyright © 2001–2015 The Apache Software Foundation. All rights reserved.