|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectariba.util.core.ClassExtension
ariba.util.fieldvalue.FieldValue
public abstract class FieldValue
The FieldValue class defines a ClassExtension
for JavaBean-like property
access on target objects. Static methods getFieldValue(Object, String)
and setFieldValue(Object, String, Object)
are provided for convenience.
Higher performance access can be achieved by caching FieldPath
instances
for particular key paths. Not only does that avoid per-access accessor lookup, but the
field path caches FieldValueSetter
and FieldValueGetter
instances
from its most recent lookup and can reuse them if the next access targets the
same class.
The default implementation of FieldValue is FieldValue_Object
-- it resolves
property access using reflection to get/set using accessor methods or direct field access.
(note that, unlike JavaBeans, FieldValue_Object will resolve a get on key "foo" by checking for
foo(), getFoo, and the fields named foo and _foo).
Other specialized implementation of FieldValue exist for Maps, XML Nodes, etc.
Field Summary | |
---|---|
static int |
Getter
|
static int |
Setter
|
Fields inherited from class ariba.util.core.ClassExtension |
---|
forClass |
Constructor Summary | |
---|---|
FieldValue()
|
Method Summary | |
---|---|
abstract FieldValueAccessor |
createAccessor(java.lang.Object target,
java.lang.String fieldName,
int type)
Creates and returns a new FieldValueAccessor (by default, a ReflectionFieldValueAccessor) for the given target and fieldName. |
static FieldValue |
get(java.lang.Class targetClass)
Retrieve a ClassExtension registered by registerClassExtension(...). |
static FieldValue |
get(java.lang.Object target)
|
abstract FieldValueAccessor |
getAccessor(java.lang.Object target,
java.lang.String fieldName,
int type)
Maintains a cache of FieldValueAccessor's for the instance by fieldName. |
abstract java.lang.Object |
getFieldValue(java.lang.Object target,
FieldPath fieldPath)
Recursively calls getFieldValuePrimitive() with the head of the fieldPath list. |
static java.lang.Object |
getFieldValue(java.lang.Object target,
java.lang.String fieldPathString)
Converts fieldPathString into a FieldPath (from a pool of shared FieldPaths) and calls getFieldValue(FieldPath). |
abstract java.lang.Object |
getFieldValuePrimitive(java.lang.Object target,
FieldPath fieldPath)
Gets the value from the reveiver using the fieldName indicated by fieldPath -- only the first node of the fieldPath is considered if it is a multi-node path. |
void |
populateFieldInfo(java.lang.Class targetClass,
FieldInfo.Collection collection)
Called by FieldInfo.fieldInfoForClass() to populate FieldInfo.Collection with information on available fields. |
static void |
registerClassExtension(java.lang.Class targetObjectClass,
FieldValue fieldValueClassExtension)
Put a ClassExtension implementation of the FieldValue interface into the cache of categories which is used to dispatch the FieldValue cover methods in this class. |
abstract void |
setFieldValue(java.lang.Object target,
FieldPath fieldPath,
java.lang.Object value)
Recursively calls getFieldValuePrimitive() with the head of the fieldPath list up to the last fieldPath node and then calls setFieldValuePrimitive(). |
static void |
setFieldValue(java.lang.Object target,
java.lang.String fieldPathString,
java.lang.Object value)
Converts fieldPathString into a FieldPath (from a pool of shared FieldPaths) and calls setFieldValue(FieldPath, Object). |
abstract void |
setFieldValuePrimitive(java.lang.Object target,
FieldPath fieldPath,
java.lang.Object value)
Sets the value on the reveiver using the fieldName indicated by fieldPath -- only the first node of the fieldPath is considered if it is a multi-node path. |
Methods inherited from class ariba.util.core.ClassExtension |
---|
clone, forClass, getRealClass, setForClass |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int Setter
public static final int Getter
Constructor Detail |
---|
public FieldValue()
Method Detail |
---|
public static void registerClassExtension(java.lang.Class targetObjectClass, FieldValue fieldValueClassExtension)
targetObjectClass
- the root class for which the classExtension appliesfieldValueClassExtension
- the classExtension implementation of the FieldValue interfacepublic static FieldValue get(java.lang.Class targetClass)
targetClass
- the class for which a classExtension applies
public static FieldValue get(java.lang.Object target)
public static void setFieldValue(java.lang.Object target, java.lang.String fieldPathString, java.lang.Object value)
target
- see the FieldPath version of this methodfieldPathString
- the dotted fieldPath String from which a shared FieldPath
instance will be obtainedvalue
- see the FieldPath version of this methodpublic static java.lang.Object getFieldValue(java.lang.Object target, java.lang.String fieldPathString)
target
- see the FieldPath version of this methodfieldPathString
- the dotted fieldPath String from which a shared FieldPath
instance will be obtained
public abstract FieldValueAccessor createAccessor(java.lang.Object target, java.lang.String fieldName, int type)
target
- the object for which the accessor will be createdfieldName
- the name of the field for which the accessor will be created
public abstract FieldValueAccessor getAccessor(java.lang.Object target, java.lang.String fieldName, int type)
target
- the object for which the accessor will be looked upfieldName
- the name of the field for the accessor
public abstract void setFieldValuePrimitive(java.lang.Object target, FieldPath fieldPath, java.lang.Object value)
target
- the object on which the value will be set for the field identiifed by
fieldPathfieldPath
- the fieldPath node (which contains a candidate accessor) to be
used to set the value on target.value
- the value to set on the targetpublic abstract java.lang.Object getFieldValuePrimitive(java.lang.Object target, FieldPath fieldPath)
target
- the object from which to get the value of the field identified by
fieldPathfieldPath
- the fieldPath node which identifes the field to get.
public abstract void setFieldValue(java.lang.Object target, FieldPath fieldPath, java.lang.Object value)
target
- the object on which to start the recursion for setting
the value using the fieldPathfieldPath
- the linked list of fieldPath nodes used to navigate from
target to the final object in the chain, upon which the value is setvalue
- the value which is set on the final object in the chainpublic abstract java.lang.Object getFieldValue(java.lang.Object target, FieldPath fieldPath)
target
- the first object from which to start the recursion for getting
the value identified by the fieldPath.fieldPath
- the linked list of fieldPath nodes that identifes the value to get
public void populateFieldInfo(java.lang.Class targetClass, FieldInfo.Collection collection)
targetClass
- class for which info should be provided.collection
- repository to populate
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |