|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.jxpath.ri.model.NodePointer
Common superclass for Pointers of all kinds. A NodePointer maps to a deterministic XPath that represents the location of a node in an object graph. This XPath uses only simple axes: child, namespace and attribute and only simple, context-independent predicates.
Field Summary | |
protected int |
index
|
protected java.util.Locale |
locale
|
protected NodePointer |
parent
|
static java.lang.String |
UNKNOWN_NAMESPACE
|
static int |
WHOLE_COLLECTION
|
Constructor Summary | |
protected |
NodePointer(NodePointer parent)
|
protected |
NodePointer(NodePointer parent,
java.util.Locale locale)
|
Method Summary | |
java.lang.String |
asPath()
Returns an XPath that maps to this Pointer. |
NodeIterator |
attributeIterator(QName qname)
Returns a NodeIterator that iterates over all attributes of the current node matching the supplied node name (could have a wildcard). |
NodeIterator |
childIterator(NodeTest test,
boolean reverse,
NodePointer startWith)
Returns a NodeIterator that iterates over all children or all children that match the given NodeTest, starting with the specified one. |
java.lang.Object |
clone()
|
abstract int |
compareChildNodePointers(NodePointer pointer1,
NodePointer pointer2)
Compares two child NodePointers and returns a positive number, zero or a positive number according to the order of the pointers. |
int |
compareTo(java.lang.Object object)
|
NodePointer |
createChild(JXPathContext context,
QName name,
int index)
Called by a child pointer when it needs to create a parent object for a non-existent collection element. |
NodePointer |
createChild(JXPathContext context,
QName name,
int index,
java.lang.Object value)
Called by a child pointer if that child needs to assign the value supplied in the createPath(context, value) call to a non-existent node. |
NodePointer |
createPath(JXPathContext context)
Called by a child pointer when it needs to create a parent object. |
NodePointer |
createPath(JXPathContext context,
java.lang.Object value)
Called directly by JXPathContext. |
abstract java.lang.Object |
getBaseValue()
Returns the value represented by the pointer before indexing. |
protected java.lang.String |
getDefaultNamespaceURI()
|
QName |
getExpandedName()
Returns a name that consists of the namespaceURI and the local name of the node. |
int |
getIndex()
If the pointer represents a collection, the index identifies an element of that collection. |
int |
getLength()
If the pointer represents a collection (or collection element), returns the length of the collection. |
java.util.Locale |
getLocale()
If the Pointer has a parent, returns the parent's locale; otherwise returns the locale specified when this Pointer was created. |
abstract QName |
getName()
Returns the name of this node. |
java.lang.String |
getNamespaceURI()
Returns the namespace URI associated with this Pointer. |
java.lang.String |
getNamespaceURI(java.lang.String prefix)
Decodes a namespace prefix to the corresponding URI. |
abstract java.lang.Object |
getNodeValue()
Returns the object the pointer points to; does not convert it to a "canonical" type. |
NodePointer |
getParent()
|
Pointer |
getPointerByID(JXPathContext context,
java.lang.String id)
Locates a node by ID. |
Pointer |
getPointerByKey(JXPathContext context,
java.lang.String key,
java.lang.String value)
Locates a node by key and value. |
java.lang.Object |
getValue()
By default, returns getNodeValue() , can be overridden to
return a "canonical" value, like for instance a DOM element should
return its string value. |
NodePointer |
getValuePointer()
If this pointer manages a transparent container, like a variable, this method returns the pointer to the contents. |
boolean |
isActual()
An actual pointer points to an existing part of an object graph, even if it is null. |
boolean |
isCollection()
Returns true if the value of the pointer is an array or
a Collection. |
protected boolean |
isDefaultNamespace(java.lang.String prefix)
Returns true if the supplied prefix represents the default namespace in the context of the current node. |
boolean |
isLanguage(java.lang.String lang)
Returns true if the selected locale name starts with the specified prefix lang, case-insensitive. |
boolean |
isLeaf()
If true, this node does not have children |
boolean |
isNode()
If false, this node is axiliary and can only be used as an intermediate in the chain of pointers. |
boolean |
isRoot()
Returns true if this Pointer has no parent. |
NodeIterator |
namespaceIterator()
Returns a NodeIterator that iterates over all namespaces of the value currently pointed at. |
NodePointer |
namespacePointer(java.lang.String namespace)
Returns a NodePointer for the specified namespace. |
static NodePointer |
newChildNodePointer(NodePointer parent,
QName name,
java.lang.Object bean)
Allocates an new child NodePointer by iterating through all installed NodePointerFactories until it finds one that can create a pointer. |
static NodePointer |
newNodePointer(QName name,
java.lang.Object bean,
java.util.Locale locale)
Allocates an entirely new NodePointer by iterating through all installed NodePointerFactories until it finds one that can create a pointer. |
void |
printPointerChain()
|
void |
remove()
Remove the node of the object graph this pointer points to. |
void |
setIndex(int index)
|
abstract void |
setValue(java.lang.Object value)
Converts the value to the required type and changes the corresponding object to that value. |
boolean |
testNode(NodeTest test)
Checks if this Pointer matches the supplied NodeTest. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static int WHOLE_COLLECTION
protected int index
public static java.lang.String UNKNOWN_NAMESPACE
protected NodePointer parent
protected java.util.Locale locale
Constructor Detail |
protected NodePointer(NodePointer parent)
protected NodePointer(NodePointer parent, java.util.Locale locale)
Method Detail |
public static NodePointer newNodePointer(QName name, java.lang.Object bean, java.util.Locale locale)
public static NodePointer newChildNodePointer(NodePointer parent, QName name, java.lang.Object bean)
public NodePointer getParent()
public boolean isRoot()
public boolean isLeaf()
public boolean isNode()
public int getIndex()
index
is WHOLE_COLLECTION
, which just means that the pointer
is not indexed at all.
Note: the index on NodePointer starts with 0, not 1.
public void setIndex(int index)
public boolean isCollection()
true
if the value of the pointer is an array or
a Collection.
public int getLength()
public java.lang.Object getValue()
getNodeValue()
, can be overridden to
return a "canonical" value, like for instance a DOM element should
return its string value.
getValue
in interface Pointer
public NodePointer getValuePointer()
public boolean isActual()
public abstract QName getName()
public abstract java.lang.Object getBaseValue()
public abstract java.lang.Object getNodeValue()
public abstract void setValue(java.lang.Object value)
setValue
in interface Pointer
public abstract int compareChildNodePointers(NodePointer pointer1, NodePointer pointer2)
public boolean testNode(NodeTest test)
public NodePointer createPath(JXPathContext context, java.lang.Object value)
public void remove()
public NodePointer createPath(JXPathContext context)
public NodePointer createChild(JXPathContext context, QName name, int index, java.lang.Object value)
public NodePointer createChild(JXPathContext context, QName name, int index)
public java.util.Locale getLocale()
public boolean isLanguage(java.lang.String lang)
public NodeIterator childIterator(NodeTest test, boolean reverse, NodePointer startWith)
public NodeIterator attributeIterator(QName qname)
public NodeIterator namespaceIterator()
public NodePointer namespacePointer(java.lang.String namespace)
public java.lang.String getNamespaceURI(java.lang.String prefix)
public java.lang.String getNamespaceURI()
protected boolean isDefaultNamespace(java.lang.String prefix)
protected java.lang.String getDefaultNamespaceURI()
public QName getExpandedName()
public Pointer getPointerByID(JXPathContext context, java.lang.String id)
public Pointer getPointerByKey(JXPathContext context, java.lang.String key, java.lang.String value)
public java.lang.String asPath()
asPath
in interface Pointer
public java.lang.Object clone()
clone
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public int compareTo(java.lang.Object object)
compareTo
in interface java.lang.Comparable
public void printPointerChain()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |