com.sun.data.provider.impl
Class ObjectFieldKeySupport

java.lang.Object
  extended by com.sun.data.provider.impl.ObjectFieldKeySupport

public class ObjectFieldKeySupport
extends java.lang.Object

Support class for DataProvider implementations that need to instrospect Java classes to discover properties (and optionally public fields) and return FieldKey instances for them.


Constructor Summary
ObjectFieldKeySupport(java.lang.Class clazz, boolean includeFields)
          Construct a new support instance wrapping the specified class, with the specified flag for including public fields.
 
Method Summary
 FieldKey getFieldKey(java.lang.String fieldId)
          Return the FieldKey associated with the specified canonical identifier, if any; otherwise, return null.
 FieldKey[] getFieldKeys()
          Return an array of all supported FieldKeys.
 java.lang.Class getType(FieldKey fieldKey)
          Return the type of the field associated with the specified FieldKey, if it can be determined; otherwise, return null.
 java.lang.Object getValue(FieldKey fieldKey, java.lang.Object base)
          Return the value for the specified FieldKey, from the specified base object.
 boolean isAssignable(FieldKey fieldKey, java.lang.Object value)
          Return true if the specified value may be successfully assigned to the specified field.
 boolean isReadOnly(FieldKey fieldKey)
          Return the read only state of the field associated with the specified FieldKey, if it can be determined, otherwise, return true.
 void setValue(FieldKey fieldKey, java.lang.Object base, java.lang.Object value)
          Set the value for the specified FieldKey, on the specified base object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectFieldKeySupport

public ObjectFieldKeySupport(java.lang.Class clazz,
                             boolean includeFields)

Construct a new support instance wrapping the specified class, with the specified flag for including public fields.

WARNING - Instances of this class will not be Serializable, so callers should not attempt to save fields containing such instances.

Parameters:
clazz - Class whose properties should be exposed
includeFields - Flag indicating whether public fields should also be included
Method Detail

getFieldKey

public FieldKey getFieldKey(java.lang.String fieldId)
                     throws DataProviderException

Return the FieldKey associated with the specified canonical identifier, if any; otherwise, return null.

Parameters:
fieldId - Canonical identifier of the required field
Throws:
DataProviderException

getFieldKeys

public FieldKey[] getFieldKeys()
                        throws DataProviderException

Return an array of all supported FieldKeys.

Throws:
DataProviderException

getType

public java.lang.Class getType(FieldKey fieldKey)
                        throws DataProviderException

Return the type of the field associated with the specified FieldKey, if it can be determined; otherwise, return null.

Parameters:
fieldKey - FieldKey to return the type for
Throws:
DataProviderException

getValue

public java.lang.Object getValue(FieldKey fieldKey,
                                 java.lang.Object base)
                          throws DataProviderException

Return the value for the specified FieldKey, from the specified base object.

Parameters:
fieldKey - FieldKey for the requested field
base - Base object to be used
Throws:
DataProviderException

isAssignable

public boolean isAssignable(FieldKey fieldKey,
                            java.lang.Object value)
                     throws DataProviderException

Return true if the specified value may be successfully assigned to the specified field.

Parameters:
fieldKey - FieldKey to check assignability for
value - Proposed value
Throws:
DataProviderException

isReadOnly

public boolean isReadOnly(FieldKey fieldKey)
                   throws DataProviderException

Return the read only state of the field associated with the specified FieldKey, if it can be determined, otherwise, return true.

Parameters:
fieldKey - FieldKey to return read only state for
Throws:
DataProviderException

setValue

public void setValue(FieldKey fieldKey,
                     java.lang.Object base,
                     java.lang.Object value)
              throws DataProviderException

Set the value for the specified FieldKey, on the specified base object.

Parameters:
fieldKey - FieldKey for the requested field
base - Base object to be used
value - Value to be set
Throws:
java.lang.IllegalArgumentException - if a type mismatch occurs
java.lang.IllegalStateException - if setting a read only field is attempted
DataProviderException