|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.data.provider.impl.AbstractDataProvider
public abstract class AbstractDataProvider
Abstract base implementation of DataProvider. This class is a
convenient base class to use when creating a new DataProvider
implementation.
| Field Summary | |
|---|---|
protected DataListener[] |
dpListeners
Array of DataListener instances registered for
this DataProvider. |
protected FieldKey[] |
fieldKeys
storage for the list of FieldKeys in this DataProvider |
| Constructor Summary | |
|---|---|
AbstractDataProvider()
|
|
| Method Summary | |
|---|---|
void |
addDataListener(DataListener listener)
Register a new |
protected void |
addFieldKey(FieldKey fieldKey)
Adds a FieldKey to the list of keys |
protected void |
addFieldKeys(FieldKey[] fieldKeys)
Adds a list of FieldKeys to the list of keys |
protected void |
clearFieldKeys()
Empties the list of FieldKeys |
protected void |
fireProviderChanged()
Fires a providerChanged event to each registered DataListener |
protected void |
fireValueChanged(FieldKey fieldKey,
java.lang.Object oldValue,
java.lang.Object newValue)
Fires a valueChanged event to each registered DataListener |
DataListener[] |
getDataListeners()
|
static java.lang.Object |
getFakeData(java.lang.Class dataType)
This helper method defers to getFakeData(Class, Class) passing
null as the collectionElementType. |
static java.lang.Object |
getFakeData(java.lang.Class dataType,
java.lang.Class collectionElementType)
This helper method produces fake data for use during design-time. |
FieldKey |
getFieldKey(java.lang.String fieldId)
Returns the |
FieldKey[] |
getFieldKeys()
|
abstract java.lang.Class |
getType(FieldKey fieldKey)
Returns the data type of the data element referenced by the specified data key. |
java.lang.Class |
getType(java.lang.String fieldId)
|
abstract java.lang.Object |
getValue(FieldKey fieldKey)
Returns value of the data element referenced by the specified
|
java.lang.Object |
getValue(java.lang.String fieldId)
|
abstract boolean |
isReadOnly(FieldKey fieldKey)
Return a flag indicating whether the value of the data element
represented by the specified |
boolean |
isReadOnly(java.lang.String fieldId)
|
void |
removeDataListener(DataListener listener)
Deregister an existing |
protected void |
removeFieldKey(FieldKey fieldKey)
Removes a FieldKey from the list of keys |
protected void |
removeFieldKeys(FieldKey[] fieldKeys)
Removes an array of FieldKeys from the list |
abstract void |
setValue(FieldKey fieldKey,
java.lang.Object value)
Set the value of the data element represented by the specified
|
void |
setValue(java.lang.String fieldId,
java.lang.Object value)
|
protected void |
sortFieldKeys()
Sorts the FieldKeys (using Arrays.sort) |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected FieldKey[] fieldKeys
FieldKeys in this DataProvider
protected DataListener[] dpListeners
Array of DataListener instances registered for
this DataProvider.
| Constructor Detail |
|---|
public AbstractDataProvider()
| Method Detail |
|---|
public abstract java.lang.Class getType(FieldKey fieldKey)
throws DataProviderException
Returns the data type of the data element referenced by the specified data key.
getType in interface DataProviderfieldKey - FieldKey identifying the data element
whose type is to be returned
DataProviderException - Implementations may wish to surface
internal exceptions (nested in DataProviderException) rather
than simply returning null. A DPE may also indicate that the
passed fieldKey is not valid. Consult the documentation of the
specific DataProvider implementation for details on what
exceptions might be wrapped by a DPE.
public abstract boolean isReadOnly(FieldKey fieldKey)
throws DataProviderException
Return a flag indicating whether the value of the data element
represented by the specified FieldKey can be modified via the
setValue() method.
isReadOnly in interface DataProviderfieldKey - FieldKey identifying the data element
whose settable status is to be returned
FieldKey can be modified
via the setValue() method
DataProviderException - Implementations may wish to surface
internal exceptions (nested in DataProviderException) rather
than simply returning true. A DPE may also indicate that the
passed fieldKey is not valid. Consult the documentation of the
specific DataProvider implementation for details on what
exceptions might be wrapped by a DPE.
public abstract java.lang.Object getValue(FieldKey fieldKey)
throws DataProviderException
Returns value of the data element referenced by the specified
FieldKey.
getValue in interface DataProviderfieldKey - FieldKey identifying the data element
whose value is to be returned
FieldKey
DataProviderException - Implementations may wish to surface
internal exceptions (nested in DataProviderException) rather
than simply returning null. A DPE may also indicate that the
passed fieldKey is not valid. Consult the documentation of the
specific DataProvider implementation for details on what
exceptions might be wrapped by a DPE.
public abstract void setValue(FieldKey fieldKey,
java.lang.Object value)
throws DataProviderException
Set the value of the data element represented by the specified
FieldKey to the specified new value.
setValue in interface DataProviderfieldKey - FieldKey identifying the data element
whose value is to be modifiedvalue - New value for this data element
DataProviderException - Implementations may wish to surface
internal exceptions (nested in DataProviderException) rather
than simply returning null. A DPE may also indicate that the
passed fieldKey is not valid. Consult the documentation of the
specific DataProvider implementation for details on what
exceptions might be wrapped by a DPE.
public java.lang.Class getType(java.lang.String fieldId)
throws DataProviderException
DataProviderException
public boolean isReadOnly(java.lang.String fieldId)
throws DataProviderException
DataProviderException
public java.lang.Object getValue(java.lang.String fieldId)
throws DataProviderException
DataProviderException
public void setValue(java.lang.String fieldId,
java.lang.Object value)
throws DataProviderException
DataProviderExceptionprotected void addFieldKey(FieldKey fieldKey)
FieldKey to the list of keys
fieldKey - FieldKey to add to the list of keysprotected void addFieldKeys(FieldKey[] fieldKeys)
FieldKeys to the list of keys
fieldKeys - FieldKey[] to add to the list of keysprotected void sortFieldKeys()
FieldKeys (using Arrays.sort)
protected void removeFieldKey(FieldKey fieldKey)
FieldKey from the list of keys
fieldKey - FieldKey to remove from the listprotected void removeFieldKeys(FieldKey[] fieldKeys)
FieldKeys from the list
fieldKeys - FieldKey[] to remove from the listprotected void clearFieldKeys()
FieldKeys
public FieldKey[] getFieldKeys()
throws DataProviderException
getFieldKeys in interface DataProviderFieldKeys supported by this
DataProvider. If the set of valid FieldKeys cannot
be determined, return null instead.
DataProviderException - Implementations may wish to surface
internal exceptions (nested in DataProviderException) rather
than simply returning null or an empty array. Consult the
documentation of the specific DataProvider implementation for
details on what exceptions might be wrapped by a DPE.
public FieldKey getFieldKey(java.lang.String fieldId)
throws DataProviderException
Returns the FieldKey associated with the specified data
element canonical id, if any; otherwise, return null.
getFieldKey in interface DataProviderfieldId - Canonical id of the requested FieldKey
FieldKey associated with the specified data
element canonical id, if any; otherwise, return
null
DataProviderException - Implementations may wish to surface
internal exceptions (nested in DataProviderException) rather
than simply returning null. A DPE may also indicate that the
passed fieldId is not valid. Consult the documentation of the
specific DataProvider implementation for details on what
exceptions might be wrapped by a DPE.public static java.lang.Object getFakeData(java.lang.Class dataType)
getFakeData(Class, Class) passing
null as the collectionElementType. This is used for design-time only
rendering of fake data.
dataType - The Class representing the type of data to fake
public static java.lang.Object getFakeData(java.lang.Class dataType,
java.lang.Class collectionElementType)
This helper method produces fake data for use during design-time. This allows a DataProvider implementation class to avoid a costly call to a database, web service, or EJB method at design-time. This will handle array and collection types as well as object types.
If the underlying type is other than a primitive type or java.lang common type, it is constructed by attempting to use the default constructor for the class, if it exists. The method will then recurse to populate the properties and fields of the nested object (avoiding recursion). If no default constructor exists, this method will return null for the value.
dataType - The Class representing the type of data to fake. This
might be a native array, Collection, or any Object subtypecollectionElementType - If the 'dataType' is a Collection type, this
parameter specifies the type of element stored in the Collection
public void addDataListener(DataListener listener)
Register a new DataListener to this DataProvider
instance.
addDataListener in interface DataProviderlistener - New DataListener to registerpublic void removeDataListener(DataListener listener)
Deregister an existing DataListener from this
DataProvider instance.
removeDataListener in interface DataProviderlistener - Old DataListener to deregisterpublic DataListener[] getDataListeners()
getDataListeners in interface DataProviderDataListeners currently
registered on this DataProvider. If there are no registered
listeners, a zero-length array is returned.
protected void fireValueChanged(FieldKey fieldKey,
java.lang.Object oldValue,
java.lang.Object newValue)
DataListener
fieldKey - FieldKey identifying the changed valueoldValue - The old value (before the change)newValue - The new value (after the change)DataListener.valueChanged(DataProvider, FieldKey, Object, Object)protected void fireProviderChanged()
DataListener
DataListener.providerChanged(DataProvider)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||