Class BeanPropertyPointer
- java.lang.Object
-
- org.apache.commons.jxpath.ri.model.NodePointer
-
- org.apache.commons.jxpath.ri.model.beans.PropertyPointer
-
- org.apache.commons.jxpath.ri.model.beans.BeanPropertyPointer
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Comparable
,Pointer
public class BeanPropertyPointer extends PropertyPointer
Pointer pointing to a property of a JavaBean.- Version:
- $Revision: 670727 $ $Date: 2008-06-23 15:10:38 -0500 (Mon, 23 Jun 2008) $
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Object
baseValue
private JXPathBeanInfo
beanInfo
private java.lang.String[]
names
private java.beans.PropertyDescriptor
propertyDescriptor
private java.beans.PropertyDescriptor[]
propertyDescriptors
private java.lang.String
propertyName
private static long
serialVersionUID
private static java.lang.Object
UNINITIALIZED
private java.lang.Object
value
-
Fields inherited from class org.apache.commons.jxpath.ri.model.beans.PropertyPointer
bean, propertyIndex, UNSPECIFIED_PROPERTY
-
Fields inherited from class org.apache.commons.jxpath.ri.model.NodePointer
index, locale, parent, UNKNOWN_NAMESPACE, WHOLE_COLLECTION
-
-
Constructor Summary
Constructors Constructor Description BeanPropertyPointer(NodePointer parent, JXPathBeanInfo beanInfo)
Create a new BeanPropertyPointer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NodePointer
createPath(JXPathContext context)
Called by a child pointer when it needs to create a parent object.java.lang.Object
getBaseValue()
Get the value of the currently selected property.java.lang.Object
getImmediateNode()
If index == WHOLE_COLLECTION, the value of the property, otherwise the value of the index'th element of the collection represented by the property.int
getLength()
If the property contains a collection, then the length of that collection, otherwise - 1.int
getPropertyCount()
Count the number of properties represented.private java.beans.PropertyDescriptor
getPropertyDescriptor()
Finds the property descriptor corresponding to the current property index.protected java.beans.PropertyDescriptor[]
getPropertyDescriptors()
Get all PropertyDescriptors.java.lang.String
getPropertyName()
Get the name of the currently selected property.java.lang.String[]
getPropertyNames()
Get the names of all properties, sorted alphabeticallyprotected boolean
isActualProperty()
Learn whether this pointer references an actual property.boolean
isCollection()
Returnstrue
if the value of the pointer is an array or a Collection.boolean
isContainer()
This type of node is auxiliary.void
remove()
Remove the node of the object graph this pointer points to.void
setIndex(int index)
Set the index of this NodePointer.void
setPropertyIndex(int index)
Selects a property by its offset in the alphabetically sorted list.void
setPropertyName(java.lang.String propertyName)
Select a property by name.void
setValue(java.lang.Object value)
If index == WHOLE_COLLECTION, change the value of the property, otherwise change the value of the index'th element of the collection represented by the property.-
Methods inherited from class org.apache.commons.jxpath.ri.model.beans.PropertyPointer
compareChildNodePointers, createChild, createChild, createPath, equals, getBean, getImmediateValuePointer, getName, getPropertyIndex, hashCode, isActual, isLeaf
-
Methods inherited from class org.apache.commons.jxpath.ri.model.NodePointer
asPath, attributeIterator, childIterator, clone, compareTo, createAttribute, escape, getAbstractFactory, getDefaultNamespaceURI, getImmediateParentPointer, getIndex, getLocale, getNamespaceResolver, getNamespaceURI, getNamespaceURI, getNode, getNodeSetByKey, getNodeValue, getParent, getPointerByID, getPointerByKey, getRootNode, getValue, getValuePointer, isAttribute, isDefaultNamespace, isLanguage, isNode, isRoot, namespaceIterator, namespacePointer, newChildNodePointer, newNodePointer, printPointerChain, setAttribute, setNamespaceResolver, testNode, toString
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
UNINITIALIZED
private static final java.lang.Object UNINITIALIZED
-
propertyName
private java.lang.String propertyName
-
beanInfo
private JXPathBeanInfo beanInfo
-
baseValue
private java.lang.Object baseValue
-
value
private java.lang.Object value
-
names
private transient java.lang.String[] names
-
propertyDescriptors
private transient java.beans.PropertyDescriptor[] propertyDescriptors
-
propertyDescriptor
private transient java.beans.PropertyDescriptor propertyDescriptor
-
-
Constructor Detail
-
BeanPropertyPointer
public BeanPropertyPointer(NodePointer parent, JXPathBeanInfo beanInfo)
Create a new BeanPropertyPointer.- Parameters:
parent
- parent pointerbeanInfo
- describes the target property/ies.
-
-
Method Detail
-
isContainer
public boolean isContainer()
This type of node is auxiliary.- Overrides:
isContainer
in classNodePointer
- Returns:
- true
-
getPropertyCount
public int getPropertyCount()
Description copied from class:PropertyPointer
Count the number of properties represented.- Specified by:
getPropertyCount
in classPropertyPointer
- Returns:
- int
-
getPropertyNames
public java.lang.String[] getPropertyNames()
Get the names of all properties, sorted alphabetically- Specified by:
getPropertyNames
in classPropertyPointer
- Returns:
- String[]
-
setPropertyName
public void setPropertyName(java.lang.String propertyName)
Select a property by name.- Specified by:
setPropertyName
in classPropertyPointer
- Parameters:
propertyName
- String name
-
setPropertyIndex
public void setPropertyIndex(int index)
Selects a property by its offset in the alphabetically sorted list.- Overrides:
setPropertyIndex
in classPropertyPointer
- Parameters:
index
- property index
-
getBaseValue
public java.lang.Object getBaseValue()
Get the value of the currently selected property.- Specified by:
getBaseValue
in classNodePointer
- Returns:
- Object value
-
setIndex
public void setIndex(int index)
Description copied from class:NodePointer
Set the index of this NodePointer.- Overrides:
setIndex
in classNodePointer
- Parameters:
index
- int
-
getImmediateNode
public java.lang.Object getImmediateNode()
If index == WHOLE_COLLECTION, the value of the property, otherwise the value of the index'th element of the collection represented by the property. If the property is not a collection, index should be zero and the value will be the property itself.- Overrides:
getImmediateNode
in classPropertyPointer
- Returns:
- Object
-
isActualProperty
protected boolean isActualProperty()
Description copied from class:PropertyPointer
Learn whether this pointer references an actual property.- Specified by:
isActualProperty
in classPropertyPointer
- Returns:
- true if actual
-
isCollection
public boolean isCollection()
Description copied from class:NodePointer
Returnstrue
if the value of the pointer is an array or a Collection.- Overrides:
isCollection
in classPropertyPointer
- Returns:
- boolean
-
getLength
public int getLength()
If the property contains a collection, then the length of that collection, otherwise - 1.- Overrides:
getLength
in classPropertyPointer
- Returns:
- int length
-
setValue
public void setValue(java.lang.Object value)
If index == WHOLE_COLLECTION, change the value of the property, otherwise change the value of the index'th element of the collection represented by the property.- Specified by:
setValue
in interfacePointer
- Specified by:
setValue
in classNodePointer
- Parameters:
value
- value to set
-
createPath
public NodePointer createPath(JXPathContext context)
Description copied from class:NodePointer
Called by a child pointer when it needs to create a parent object. Must create an object described by this pointer and return a new pointer that properly describes the new object.- Overrides:
createPath
in classPropertyPointer
- Parameters:
context
- the owning JXPathContext- Returns:
- created NodePointer
-
remove
public void remove()
Description copied from class:NodePointer
Remove the node of the object graph this pointer points to.- Overrides:
remove
in classNodePointer
-
getPropertyName
public java.lang.String getPropertyName()
Get the name of the currently selected property.- Specified by:
getPropertyName
in classPropertyPointer
- Returns:
- String property name
-
getPropertyDescriptor
private java.beans.PropertyDescriptor getPropertyDescriptor()
Finds the property descriptor corresponding to the current property index.- Returns:
- PropertyDescriptor
-
getPropertyDescriptors
protected java.beans.PropertyDescriptor[] getPropertyDescriptors()
Get all PropertyDescriptors.- Returns:
- PropertyDescriptor[]
-
-