ariba.util.fieldvalue
Class FieldValue_Object

java.lang.Object
  extended by ariba.util.core.ClassExtension
      extended by ariba.util.fieldvalue.FieldValue
          extended by ariba.util.fieldvalue.FieldValue_Object
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
AWEvaluateTemplateFile.FieldValue, AWStringsFieldValueClassExtension, Context.FieldValue_ContextPropertyAccessor, FieldValue_AWSubcomponent, FieldValue_ConvertibleFieldValue, FieldValue_Extensible, FieldValue_JavaHashtable, MetaRange.FieldValue_ValueRedirector, XMLUtil.FieldValue_XMLNode

public class FieldValue_Object
extends FieldValue

The FieldValue_Object class extension is the default implementation of the FieldValue interface. This default implementation is based on java.lang.reflection primitives and will work for essentailly all classes. Of course, certain subclasses may desire to alter the default behavior and, as such, should subclass this class and override the appropriate methods. For example, a Map implementation may want to treat the fieldName as a key for get/put rather than as the name of an instance variable. Some other subclass may desire to mix and match the two approaches. In any case, these special cases should be implemented in subclasses of FieldValue_Object.


Field Summary
 
Fields inherited from class ariba.util.fieldvalue.FieldValue
Getter, Setter
 
Fields inherited from class ariba.util.core.ClassExtension
forClass
 
Constructor Summary
FieldValue_Object()
           
 
Method Summary
 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.
 FieldValueAccessor getAccessor(java.lang.Object target, java.lang.String fieldName, int type)
          Maintains a cache of FieldValueAccessor's for the instance by fieldName.
 java.lang.Object getFieldValue(java.lang.Object target, FieldPath fieldPath)
          Recursively calls getFieldValuePrimitive() with the head of the fieldPath list.
 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.
 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().
 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.fieldvalue.FieldValue
get, get, getFieldValue, registerClassExtension, setFieldValue
 
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
 

Constructor Detail

FieldValue_Object

public FieldValue_Object()
Method Detail

createAccessor

public 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. No caching is done by this method. This method is designed to be overridden by subclasses of FieldValue_Object which want to define their own specialized accessors. Note that the target is passed rather than its class so that accessors can be created at a finer granularity than class. Certain meta-data driven classes require this flexibility.

Specified by:
createAccessor in class FieldValue
Parameters:
target - the object for which the accessor will be created
fieldName - the name of the field for which the accessor will be created
type - the type of accessor will be created (either FieldValue.Setter or FieldValue.Getter)
Returns:
a new FieldValueAccessor (ReflectionFieldValueAccessor by default)

getAccessor

public FieldValueAccessor getAccessor(java.lang.Object target,
                                      java.lang.String fieldName,
                                      int type)
Maintains a cache of FieldValueAccessor's for the instance by fieldName. In general, all instances of a given class will share the same FieldValueAccessor for a given fieldName. However, certain meta-data driven classes may need to introspect upon the instance before returning the proper accessor.

Specified by:
getAccessor in class FieldValue
Parameters:
target - the object for which the accessor will be looked up
fieldName - the name of the field for the accessor
type - the type of accessor will be created (either FieldValue.Setter or FieldValue.Getter)
Returns:
the cached FieldValueAccessor (ReflectionFieldValueAccessor by default)

setFieldValuePrimitive

public 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.

Specified by:
setFieldValuePrimitive in class FieldValue
Parameters:
target - the object on which the value will be set for the field identiifed by fieldPath
fieldPath - the fieldPath node (which contains a candidate accessor) to be used to set the value on target.
value - the value to set on the target

getFieldValuePrimitive

public 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.

Specified by:
getFieldValuePrimitive in class FieldValue
Parameters:
target - the object from which to get the value of the field identified by fieldPath
fieldPath - the fieldPath node which identifes the field to get.
Returns:
the value obtained from the target using the fieldPath

setFieldValue

public 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(). Each time the recursion iterates, the receiver is the value of the previous getFieldValuePrimitive().

Specified by:
setFieldValue in class FieldValue
Parameters:
target - the object on which to start the recursion for setting the value using the fieldPath
fieldPath - the linked list of fieldPath nodes used to navigate from target to the final object in the chain, upon which the value is set
value - the value which is set on the final object in the chain

getFieldValue

public java.lang.Object getFieldValue(java.lang.Object target,
                                      FieldPath fieldPath)
Recursively calls getFieldValuePrimitive() with the head of the fieldPath list. Each time the recursion iterates, the receiver is the value of the previous getFieldValuePrimitive().

Specified by:
getFieldValue in class FieldValue
Parameters:
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
Returns:
the value obtained from the last object in the chain

populateFieldInfo

public void populateFieldInfo(java.lang.Class targetClass,
                              FieldInfo.Collection collection)
Description copied from class: FieldValue
Called by FieldInfo.fieldInfoForClass() to populate FieldInfo.Collection with information on available fields. Implementing FieldValue extensions should callback with FieldInfo.Collection.updateFieldInfo() to provide information for all usable fields. Fields should be populated in a first-declaration-first manner -- i.e. super class before class, fields in java declaraion order where possible -- registration order is used to determine the "rank" recorded on the field.

Overrides:
populateFieldInfo in class FieldValue
Parameters:
targetClass - class for which info should be provided.
collection - repository to populate


AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.