com.sun.data.provider.impl
Class BasicTransactionalDataProvider

java.lang.Object
  extended by com.sun.data.provider.impl.AbstractDataProvider
      extended by com.sun.data.provider.impl.BasicTransactionalDataProvider
All Implemented Interfaces:
DataProvider, TransactionalDataProvider, java.io.Serializable

public class BasicTransactionalDataProvider
extends AbstractDataProvider
implements TransactionalDataProvider

See Also:
Serialized Form

Field Summary
protected  java.util.HashMap changeMap
           
protected  DataListener ears
           
protected  DataProvider provider
           
 
Fields inherited from class com.sun.data.provider.impl.AbstractDataProvider
dpListeners, fieldKeys
 
Constructor Summary
BasicTransactionalDataProvider()
           
 
Method Summary
 void addTransactionalDataListener(TransactionalDataListener l)
          

Register a new TransactionalDataListener to this TransactionalDataProvider instance.

 void commitChanges()
          Cause any cached changes to values of data elements supported by this DataProvider to be passed through to the underlying data structure.
protected  void fireChangesCommitted()
          Fires a changesCommtted event to each registered TransactionalDataListener
protected  void fireChangesReverted()
          Fires a changesReverted event to each registered TransactionalDataListener
 DataProvider getDataProvider()
           
 FieldKey getFieldKey(java.lang.String fieldId)
          

Returns the FieldKey associated with the specified data element canonical id, if any; otherwise, return null.

 FieldKey[] getFieldKeys()
          
 TransactionalDataListener[] getTransactionalDataListeners()
          
 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 value of the data element referenced by the specified FieldKey.

 boolean isReadOnly(FieldKey fieldKey)
          

Return a flag indicating whether the value of the data element represented by the specified FieldKey can be modified via the setValue() method.

 void removeTransactionalDataListener(TransactionalDataListener l)
          

Deregister an existing TransactionalDataListener from TransactionalDataProvider instance.

 void revertChanges()
          Cause any cached changes to values of data elements supported by this DataProvider to be thrown away, so that the initial values are again visible.
 void setDataProvider(DataProvider provider)
           
 void setValue(FieldKey fieldKey, java.lang.Object value)
          

Set the value of the data element represented by the specified FieldKey to the specified new value.

 
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
 
Methods inherited from interface com.sun.data.provider.DataProvider
addDataListener, getDataListeners, removeDataListener
 

Field Detail

provider

protected DataProvider provider

changeMap

protected java.util.HashMap changeMap

ears

protected DataListener ears
Constructor Detail

BasicTransactionalDataProvider

public BasicTransactionalDataProvider()
Method Detail

setDataProvider

public void setDataProvider(DataProvider provider)
Parameters:
provider - DataProvider

getDataProvider

public DataProvider getDataProvider()
Returns:
DataProvider

getFieldKeys

public FieldKey[] getFieldKeys()
                        throws DataProviderException

Specified by:
getFieldKeys in interface DataProvider
Overrides:
getFieldKeys in class AbstractDataProvider
Returns:
An array of all FieldKeys supported by this DataProvider. If the set of valid FieldKeys cannot be determined, return null instead.
Throws:
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.

getFieldKey

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.

Specified by:
getFieldKey in interface DataProvider
Overrides:
getFieldKey in class AbstractDataProvider
Parameters:
fieldId - Canonical id of the requested FieldKey
Returns:
the FieldKey associated with the specified data element canonical id, if any; otherwise, return null
Throws:
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.

getType

public java.lang.Class getType(FieldKey fieldKey)
                        throws DataProviderException
Description copied from class: AbstractDataProvider

Returns the data type of the data element referenced by the specified data key.

Specified by:
getType in interface DataProvider
Specified by:
getType in class AbstractDataProvider
Parameters:
fieldKey - FieldKey
Returns:
Class
Throws:
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.

getValue

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

Returns value of the data element referenced by the specified FieldKey.

Specified by:
getValue in interface DataProvider
Specified by:
getValue in class AbstractDataProvider
Parameters:
fieldKey - FieldKey identifying the data element whose value is to be returned
Returns:
value of the data element referenced by the specified FieldKey
Throws:
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.

isReadOnly

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

Specified by:
isReadOnly in interface DataProvider
Specified by:
isReadOnly in class AbstractDataProvider
Parameters:
fieldKey - FieldKey identifying the data element whose settable status is to be returned
Returns:
a flag indicating whether the value of the data element represented by the specified FieldKey can be modified via the setValue() method
Throws:
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.

setValue

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

Specified by:
setValue in interface DataProvider
Specified by:
setValue in class AbstractDataProvider
Parameters:
fieldKey - FieldKey identifying the data element whose value is to be modified
value - New value for this data element
Throws:
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.

commitChanges

public void commitChanges()
                   throws DataProviderException
Description copied from interface: TransactionalDataProvider

Cause any cached changes to values of data elements supported by this DataProvider to be passed through to the underlying data structure.

Specified by:
commitChanges in interface TransactionalDataProvider
Throws:
DataProviderException - Implementations may wish to surface internal exceptions (nested in DataProviderException). Consult the documentation of the specific DataProvider implementation for details on what exceptions might be wrapped by a DPE.

revertChanges

public void revertChanges()
                   throws DataProviderException
Description copied from interface: TransactionalDataProvider

Cause any cached changes to values of data elements supported by this DataProvider to be thrown away, so that the initial values are again visible.

Specified by:
revertChanges in interface TransactionalDataProvider
Throws:
DataProviderException - Implementations may wish to surface internal exceptions (nested in DataProviderException). Consult the documentation of the specific DataProvider implementation for details on what exceptions might be wrapped by a DPE.

addTransactionalDataListener

public void addTransactionalDataListener(TransactionalDataListener l)

Register a new TransactionalDataListener to this TransactionalDataProvider instance.

Specified by:
addTransactionalDataListener in interface TransactionalDataProvider
Parameters:
l - New TransactionalDataListener to register

removeTransactionalDataListener

public void removeTransactionalDataListener(TransactionalDataListener l)

Deregister an existing TransactionalDataListener from TransactionalDataProvider instance.

Specified by:
removeTransactionalDataListener in interface TransactionalDataProvider
Parameters:
l - Old TransactionalDataListener to remove

getTransactionalDataListeners

public TransactionalDataListener[] getTransactionalDataListeners()

Specified by:
getTransactionalDataListeners in interface TransactionalDataProvider
Returns:
An array of the TransactionalDataListeners currently registered on this TransactionalDataProvider. If there are no registered listeners, a zero-length array is returned.

fireChangesCommitted

protected void fireChangesCommitted()
Fires a changesCommtted event to each registered TransactionalDataListener

See Also:
TransactionalDataListener.changesCommitted(TransactionalDataProvider)

fireChangesReverted

protected void fireChangesReverted()
Fires a changesReverted event to each registered TransactionalDataListener

See Also:
TransactionalDataListener.changesReverted(TransactionalDataProvider)