|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.data.provider.impl.AbstractDataProvider
com.sun.data.provider.impl.MapDataProvider
public class MapDataProvider
This DataProvider wraps access to a standard
Map. This class can use regular MapDataProvider.MapFieldKey objects as keys
(Map key will be the FieldKey's fieldId), or can use MapDataProvider.MapFieldKey
objects if a non-string key is desired.
NOTE about Serializable: By default, this class uses a HashMap
as its internal data storage, which is a Serializable implementation of
Map. The internal storage can be swapped out using the
setMap(Map) method. For this class to remain Serializable,
the contained Map must be a Serializable implementation. Also, and more
importantly, the contents of the storage Map must be Serializable as well
for this class to successfully be serialized.
| Nested Class Summary | |
|---|---|
class |
MapDataProvider.MapFieldKey
MapFieldKey is a FieldKey that contains an untyped Object to use
as a key for a map value. |
| Field Summary | |
|---|---|
protected java.util.Map |
map
The internal storage Map, initially a HashMap |
| Fields inherited from class com.sun.data.provider.impl.AbstractDataProvider |
|---|
dpListeners, fieldKeys |
| Constructor Summary | |
|---|---|
MapDataProvider()
Constructs a new MapDataProvider using a default HashMap as the
internal storage. |
|
MapDataProvider(java.util.Map map)
Constructs a new MapDataProvider using the specified Map as the internal storage. |
|
| Method Summary | |
|---|---|
FieldKey |
getFieldKey(java.lang.String fieldId)
Returns a MapDataProvider.MapFieldKey corresponding to the specified id. |
FieldKey[] |
getFieldKeys()
|
java.util.Map |
getMap()
|
java.lang.Class |
getType(FieldKey fieldKey)
Returns the data type of the data element referenced by the specified data key. |
java.lang.Object |
getValue(FieldKey fieldKey)
Returns the value stored under the specified FieldKey in the Map. |
boolean |
isReadOnly(FieldKey fieldKey)
None of the Map entries are read-only, so this method always returns false. |
protected void |
refreshFieldKeys()
Refreshes the list of FieldKeys to reflect the current contents of the Map. |
void |
setMap(java.util.Map map)
Sets the Map to use as internal storage. |
void |
setValue(FieldKey fieldKey,
java.lang.Object value)
Puts the specified value in the Map under the specified FieldKey. |
| Methods inherited from class com.sun.data.provider.impl.AbstractDataProvider |
|---|
addDataListener, addFieldKey, addFieldKeys, clearFieldKeys, fireProviderChanged, fireValueChanged, getDataListeners, getFakeData, getFakeData, getType, getValue, isReadOnly, removeDataListener, removeFieldKey, removeFieldKeys, setValue, sortFieldKeys |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.util.Map map
Map, initially a HashMap
| Constructor Detail |
|---|
public MapDataProvider()
HashMap as the
internal storage.
public MapDataProvider(java.util.Map map)
Constructs a new MapDataProvider using the specified Map as the internal storage.
NOTE about Serializable: By default, this class uses a HashMap
as its internal data storage, which is a Serializable implementation of
Map. The internal storage can be swapped out using the
setMap(Map) method. For this class to remain Serializable,
the contained Map must be a Serializable implementation. Also, and more
importantly, the contents of the storage Map must be Serializable as well
for this class to successfully be serialized.
map - The Map to use as internal storage| Method Detail |
|---|
public java.util.Map getMap()
public void setMap(java.util.Map map)
Sets the Map to use as internal storage.
NOTE about Serializable: By default, this class uses a HashMap
as its internal data storage, which is a Serializable implementation of
Map. The internal storage can be swapped out using the
setMap(Map) method. For this class to remain Serializable,
the contained Map must be a Serializable implementation. Also, and more
importantly, the contents of the storage Map must be Serializable as well
for this class to successfully be serialized.
map - Map to use as internal storageprotected void refreshFieldKeys()
public FieldKey[] getFieldKeys()
throws DataProviderException
AbstractDataProvider
getFieldKeys in interface DataProvidergetFieldKeys in class AbstractDataProviderDataProviderException - 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
MapDataProvider.MapFieldKey corresponding to the specified id.
getFieldKey in interface DataProvidergetFieldKey in class AbstractDataProviderfieldId - The desired id to retrieve a FieldKey for
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 java.lang.Object getValue(FieldKey fieldKey)
throws DataProviderException
MapDataProvider.MapFieldKey or a MapDataProvider.MapFieldKey.
getValue in interface DataProvidergetValue in class AbstractDataProviderfieldKey - The desired FieldKey to retieve the value for
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(FieldKey fieldKey)
throws DataProviderException
AbstractDataProviderReturns the data type of the data element referenced by the specified data key.
getType in interface DataProvidergetType in class AbstractDataProviderfieldKey - 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 boolean isReadOnly(FieldKey fieldKey)
throws DataProviderException
isReadOnly in interface DataProviderisReadOnly in class AbstractDataProviderfieldKey - The specified FieldKey (ignored)
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 void setValue(FieldKey fieldKey,
java.lang.Object value)
throws DataProviderException
MapDataProvider.MapFieldKey, the MapFieldKey.mapKey will be
used as the key, otherwise the FieldKey.id will be used as the key in the
underlying Map. This method will result in a valueChanged event being
fired to all DataListener that are
listening to this DataProvider.
setValue in interface DataProvidersetValue in class AbstractDataProviderfieldKey - The desired FieldKey to store the value undervalue - The desired Object to store in the Map
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.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||