|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.data.provider.impl.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 FieldKey s 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 FieldKey s to the list of keys |
protected void |
clearFieldKeys()
Empties the list of FieldKey s |
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 FieldKey s 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 FieldKey s (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
FieldKey
s 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 DataProvider
fieldKey
- 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 DataProvider
fieldKey
- 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 DataProvider
fieldKey
- 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 DataProvider
fieldKey
- 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
DataProviderException
protected void addFieldKey(FieldKey fieldKey)
FieldKey
to the list of keys
fieldKey
- FieldKey to add to the list of keysprotected void addFieldKeys(FieldKey[] fieldKeys)
FieldKey
s to the list of keys
fieldKeys
- FieldKey[] to add to the list of keysprotected void sortFieldKeys()
FieldKey
s (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)
FieldKey
s from the list
fieldKeys
- FieldKey[] to remove from the listprotected void clearFieldKeys()
FieldKey
s
public FieldKey[] getFieldKeys() throws DataProviderException
getFieldKeys
in interface DataProvider
FieldKey
s supported by this
DataProvider
. If the set of valid FieldKey
s 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 DataProvider
fieldId
- 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 DataProvider
listener
- New DataListener
to registerpublic void removeDataListener(DataListener listener)
Deregister an existing DataListener
from this
DataProvider instance.
removeDataListener
in interface DataProvider
listener
- Old DataListener
to deregisterpublic DataListener[] getDataListeners()
getDataListeners
in interface DataProvider
DataListener
s 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 |