|
||||||||||
| 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.AbstractTableDataProvider
com.sun.data.provider.impl.CachedRowSetDataProvider
public class CachedRowSetDataProvider
TableDataProvider implementation that wraps a CachedRowSet.
Note: valueChanged events will only fire for column changes made via the CachedRowSetDataProvider
Note: The lifetime of the RowKeys handed out
CachedRowSetDataProvider is until the underlying CachedRowSet
is closed or reexecuted.
| Field Summary | |
|---|---|
protected RowKey |
cursorRow
storage for the current cursor row |
| Fields inherited from class com.sun.data.provider.impl.AbstractTableDataProvider |
|---|
rowKeyList, rowKeyMap, tcListeners |
| Fields inherited from class com.sun.data.provider.impl.AbstractDataProvider |
|---|
dpListeners |
| Constructor Summary | |
|---|---|
CachedRowSetDataProvider()
Construct an unconfigured CachedRowSetDataProvider. |
|
CachedRowSetDataProvider(javax.sql.rowset.CachedRowSet cachedRowSet)
Construct a CachedRowSetDataProvider that wraps the
specified CachedRowSet. |
|
| Method Summary | |
|---|---|
void |
addRefreshableDataListener(RefreshableDataListener listener)
Register a new |
void |
addTransactionalDataListener(TransactionalDataListener listener)
Register a new |
RowKey |
appendRow()
Appends a new row at the end of the list and returns the row key for the newly appended row. NOTE: The method should only be called after testing the
|
boolean |
canAppendRow()
This method is called to test if this TableDataProvider supports
the append operation. If rows can be appended to the list, this method
should return |
boolean |
canInsertRow(RowKey beforeRow)
This method is called to test if this TableDataProvider supports
resizability. If objects can be inserted and removed from the list,
this method should return The following methods will only be called if this method returns
|
boolean |
canRemoveRow(RowKey row)
This method is called to test if this TableDataProvider supports
the removeRow operation. If rows can be removed from the table, this
method should return |
protected void |
checkExecute()
Check if rowset, if so, execute if necessary. |
void |
close()
free resources used by this instance Close is guaranteed not to throw an exception. |
void |
commitChanges()
Cause any cached changes to values of data elements supported by this
|
boolean |
cursorFirst()
Move the cursor to the first row in this TableDataProvider. |
boolean |
cursorLast()
Move the cursor to the last row in this TableDataProvider. |
boolean |
cursorNext()
Move the cursor to the row after the current cursor row, unless the
cursor is currently at the last row |
boolean |
cursorPrevious()
Move the cursor to the row before the current cursor row, unless the cursor is currently at the first row. |
protected void |
fireChangesCommitted()
Fires a changesCommtted event to each registered TransactionalDataListener. |
protected void |
fireChangesReverted()
Fires a changesReverted event to each registered TransactionalDataListener. |
RowKey[] |
getAllRows()
Returns all the RowKeys, which may force the underlying dataprovider to go and perform an expensive operation to fetch them. |
javax.sql.rowset.CachedRowSet |
getCachedRowSet()
Return the CachedRowSet that we are wrapping. |
protected int |
getCursorIndex()
|
RowKey |
getCursorRow()
|
FieldKey |
getFieldKey(java.lang.String fieldId)
Returns the |
FieldKey[] |
getFieldKeys()
|
RefreshableDataListener[] |
getRefreshableDataListeners()
|
int |
getRowCount()
|
RowKey |
getRowKey(java.lang.String rowId)
Returns a RowKey for the specified rowId. |
RowKey[] |
getRowKeys(int count,
RowKey afterRow)
Returns an array of RowKey objects representing the requested
batch of RowKeys. If null is passed as the afterRow
parameter, the returned batch of RowKeys will start with the first one. |
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,
RowKey row)
Return value of the data element referenced by the specified
|
RowKey |
insertRow(RowKey beforeRow)
Inserts a new row at the specified row. NOTE: The method should only be called after testing the
|
boolean |
isReadOnly(FieldKey fieldKey)
Return a flag indicating whether the value of the data element
represented by the specified |
boolean |
isRowAvailable(RowKey row)
Returns true if the specified RowKey represents
data elements that are supported by this TableDataProvider;
otherwise, return false |
void |
refresh()
Cause a re-fetch of whatever data this |
void |
removeRefreshableDataListener(RefreshableDataListener listener)
Deregister an existing |
void |
removeRow(RowKey row)
Removes the specified row. NOTE: The method should only be called after testing the
|
void |
removeTransactionalDataListener(TransactionalDataListener listener)
Deregister an existing |
void |
revertChanges()
Cause any cached changes to values of data elements supported by this
|
void |
setCachedRowSet(javax.sql.rowset.CachedRowSet cachedRowSet)
Set the CachedRowSet that we are wrapping. |
protected boolean |
setCursorIndex(int index)
|
void |
setCursorRow(RowKey row)
Sets the cursor to the row represented by the passed |
void |
setValue(FieldKey fieldKey,
RowKey row,
java.lang.Object value)
Sets the value of the data element represented by the specified
|
| Methods inherited from class com.sun.data.provider.impl.AbstractTableDataProvider |
|---|
addTableCursorListener, addTableDataListener, findAll, findAll, findAll, findAll, findFirst, findFirst, findFirst, findFirst, fireCursorChanged, fireCursorChanging, fireRowAdded, fireRowRemoved, fireValueChanged, getTableCursorListeners, getTableDataListeners, getValue, getValue, removeTableCursorListener, removeTableDataListener, setValue, setValue |
| 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.TableDataProvider |
|---|
addTableCursorListener, addTableDataListener, getTableCursorListeners, getTableDataListeners, removeTableCursorListener, removeTableDataListener |
| Methods inherited from interface com.sun.data.provider.DataProvider |
|---|
addDataListener, getDataListeners, getValue, removeDataListener, setValue |
| Methods inherited from interface com.sun.data.provider.DataProvider |
|---|
addDataListener, getDataListeners, getValue, removeDataListener, setValue |
| Methods inherited from interface com.sun.data.provider.DataProvider |
|---|
addDataListener, getDataListeners, getValue, removeDataListener, setValue |
| Field Detail |
|---|
protected RowKey cursorRow
| Constructor Detail |
|---|
public CachedRowSetDataProvider()
Construct an unconfigured CachedRowSetDataProvider.
public CachedRowSetDataProvider(javax.sql.rowset.CachedRowSet cachedRowSet)
Construct a CachedRowSetDataProvider that wraps the
specified CachedRowSet.
cachedRowSet - The CachedRowSet to be wrapped| Method Detail |
|---|
public javax.sql.rowset.CachedRowSet getCachedRowSet()
Return the CachedRowSet that we are wrapping.
public void setCachedRowSet(javax.sql.rowset.CachedRowSet cachedRowSet)
Set the CachedRowSet that we are wrapping. In addition,
ensure that the CachedRowSet has been executed so that
subseuqent calls accessing it will work.
cachedRowSet - The new CachedRowSetpublic void close()
public RowKey[] getRowKeys(int count,
RowKey afterRow)
throws DataProviderException
RowKey objects representing the requested
batch of RowKeys. If null is passed as the afterRow
parameter, the returned batch of RowKeys will start with the first one.
getRowKeys in interface TableDataProvidergetRowKeys in class AbstractTableDataProvidercount - The desired count of RowKeys to fetch. If this number
exceeds the total number of rows available, the return array
will contain the available number, and no exception will be
thrown. Consider this an optimistic request of the
TableDataProvider.afterRow - The RowKey that represents the last row before the set
of desired RowKeys to be returned. Typically, this is the last
RowKey from the previously fetched set of RowKeys. If
null is passed, the returned set will begin with the
first row.
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 TableDataProvider implementation
for details on what exceptions might be wrapped by a DPE.
public RowKey[] getAllRows()
throws DataProviderException
getAllRows in class AbstractTableDataProviderDataProviderException
public RowKey getRowKey(java.lang.String rowId)
throws DataProviderException
TableDataProvider
getRowKey in interface TableDataProvidergetRowKey in class AbstractTableDataProviderrowId - The cannoncial string ID of the desired RowKey
null if the specified rowId does not correspond to
a row in this TableDataProvider
DataProviderException - Implementations may wish to surface
internal exceptions (nested in DataProviderException) rather
than simply returning null. Consult the documentation of the
specific TableDataProvider implementation for details on what
exceptions might be wrapped by a DPE.protected int getCursorIndex()
getCursorIndex in class AbstractTableDataProviderprotected boolean setCursorIndex(int index)
setCursorIndex in class AbstractTableDataProvider
public RowKey getCursorRow()
throws DataProviderException
getCursorRow in interface TableDataProvidergetCursorRow in class AbstractTableDataProviderRowKey of the current cursor row position
DataProviderException - Implementations may wish to surface
internal exceptions (nested in DataProviderException). Consult
the documentation of the specific TableDataProvider
implementation for details on what exceptions might be wrapped
by a DPE.
public void setCursorRow(RowKey row)
throws TableCursorVetoException
Sets the cursor to the row represented by the passed RowKey.
setCursorRow in interface TableDataProvidersetCursorRow in class AbstractTableDataProviderrow - New RowKey to move the cursor to.
TableCursorVetoException - if a TableCursorListener decides to
veto the cursor navigation
public boolean cursorFirst()
throws DataProviderException
Move the cursor to the first row in this TableDataProvider.
cursorFirst in interface TableDataProvidercursorFirst in class AbstractTableDataProvidertrue if the cursor row was successfully changed;
else false
DataProviderException - Implementations may wish to surface
internal exceptions (nested in DataProviderException) rather
than simply returning false. Consult the documentation of the
specific TableDataProvider implementation for details on what
exceptions might be wrapped by a DPE.
public boolean cursorNext()
throws DataProviderException
Move the cursor to the row after the current cursor row, unless the
cursor is currently at the last row TableDataProvider.
cursorNext in interface TableDataProvidercursorNext in class AbstractTableDataProvidertrue if the cursor row was successfully changed;
else false
DataProviderException - Implementations may wish to surface
internal exceptions (nested in DataProviderException) rather
than simply returning false. Consult the documentation of the
specific TableDataProvider implementation for details on what
exceptions might be wrapped by a DPE.
public boolean cursorPrevious()
throws DataProviderException
Move the cursor to the row before the current cursor row, unless the cursor is currently at the first row.
cursorPrevious in interface TableDataProvidercursorPrevious in class AbstractTableDataProvidertrue if the cursor row was successfully changed;
else false
DataProviderException - Implementations may wish to surface
internal exceptions (nested in DataProviderException) rather
than simply returning false. Consult the documentation of the
specific TableDataProvider implementation for details on what
exceptions might be wrapped by a DPE.
public boolean cursorLast()
throws DataProviderException
Move the cursor to the last row in this TableDataProvider.
cursorLast in interface TableDataProvidercursorLast in class AbstractTableDataProvidertrue if the cursor row was successfully changed;
else false
DataProviderException - Implementations may wish to surface
internal exceptions (nested in DataProviderException) rather
than simply returning false. Consult the documentation of the
specific TableDataProvider 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 DataProvidergetFieldKey in class AbstractDataProviderfieldId - 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 FieldKey[] getFieldKeys()
throws DataProviderException
getFieldKeys in interface DataProvidergetFieldKeys in class AbstractDataProviderFieldKeys 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 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 DataProvidergetType in class AbstractTableDataProviderfieldKey - 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 RowKey appendRow()
throws DataProviderException
Appends a new row at the end of the list and returns the row key for the newly appended row.
NOTE: The method should only be called after testing the
canAppendRow() method to see if this TableDataProvider
supports the append operation.
appendRow in interface TableDataProviderappendRow in class AbstractTableDataProviderDataProviderException - Implementations may wish to surface
internal exceptions (nested in DataProviderException). Consult
the documentation of the specific TableDataProvider
implementation for details on what exceptions might be wrapped
by a DPE.TableDataProvider.canAppendRow()
public boolean canInsertRow(RowKey beforeRow)
throws DataProviderException
This method is called to test if this TableDataProvider supports
resizability. If objects can be inserted and removed from the list,
this method should return true. If the data provider is
not resizable, this method should return false.
The following methods will only be called if this method returns
true:
insertRow(RowKey beforeRow)
appendRow()
removeRow(RowKey rowKey)
canInsertRow in interface TableDataProvidercanInsertRow in class AbstractTableDataProviderbeforeRow - The desired location to insert the new row in front of
true if the data provider is resizable, or
false if not.
DataProviderException - Implementations may wish to surface
internal exceptions (nested in DataProviderException) rather
than simply returning false. A DPE may also indicate that this
RowKey does not represent a row provided by this
TableDataProvider. Consult the documentation of the specific
TableDataProvider implementation for details on what exceptions
might be wrapped by a DPE.TableDataProvider.insertRow(RowKey)
public boolean canAppendRow()
throws DataProviderException
This method is called to test if this TableDataProvider supports
the append operation. If rows can be appended to the list, this method
should return true. If the data provider is not resizable,
or cannot support an append operation, this method should return
false.
canAppendRow in interface TableDataProvidercanAppendRow in class AbstractTableDataProvidertrue if the data provider supports the append
operation, or false if not.
DataProviderException - Implementations may wish to surface
internal exceptions (nested in DataProviderException). A DPE
may also indicate that this RowKey does not
represent a row provided by this TableDataProvider. Consult the
documentation of the specific TableDataProvider implementation
for details on what exceptions might be wrapped by a DPE.TableDataProvider.appendRow()
public boolean canRemoveRow(RowKey row)
throws DataProviderException
This method is called to test if this TableDataProvider supports
the removeRow operation. If rows can be removed from the table, this
method should return true. If the data provider is does
not support removing rows, this method should return false.
canRemoveRow in interface TableDataProvidercanRemoveRow in class AbstractTableDataProviderrow - The desired row to remove
true if the data provider supports removing rows,
or false if not.
DataProviderException - Implementations may wish to surface
internal exceptions (nested in DataProviderException). A DPE
may also indicate that this RowKey does not
represent a row provided by this TableDataProvider. Consult
the documentation of the specific TableDataProvider
implementation for details on what exceptions might be wrapped
by a DPE.TableDataProvider.removeRow(RowKey)
public int getRowCount()
throws DataProviderException
getRowCount in interface TableDataProvidergetRowCount in class AbstractTableDataProviderTableDataProvider if this information is available;
otherwise, return -1 (indicating unknown row count)
DataProviderException - Implementations may wish to surface
internal exceptions (nested in DataProviderException) rather
than simply returning -1. Consult the documentation of the
specific TableDataProvider implementation for details on what
exceptions might be wrapped by a DPE.
public java.lang.Object getValue(FieldKey fieldKey,
RowKey row)
throws DataProviderException
Return value of the data element referenced by the specified
FieldKey and RowKey.
getValue in interface TableDataProvidergetValue in class AbstractTableDataProviderfieldKey - FieldKey identifying the data element
whose value is to be returnedrow - RowKey identifying the data row whose value
is to be returned
FieldKey and RowKey
DataProviderException - Implementations may wish to surface
internal exceptions (nested in DataProviderException) rather
than simply returning null. A DPE may also indicate that this
FieldKey or RowKey does not represent
a data element provided by this TableDataProvider. Consult the
documentation of the specific TableDataProvider implementation
for details on what exceptions might be wrapped by a DPE.
public RowKey insertRow(RowKey beforeRow)
throws DataProviderException
Inserts a new row at the specified row.
NOTE: The method should only be called after testing the
canInsertRow(RowKey beforeRow) to see if this
TableDataProvider supports resizing.
insertRow in interface TableDataProviderinsertRow in class AbstractTableDataProviderbeforeRow - The desired location to insert the new row in front of
DataProviderException - Implementations may wish to surface
internal exceptions (nested in DataProviderException). A DPE
may also indicate that this RowKey does not
represent a row provided by this TableDataProvider. Consult the
documentation of the specific TableDataProvider implementation
for details on what exceptions might be wrapped by a DPE.TableDataProvider.canInsertRow(RowKey)
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.
isReadOnly in interface DataProviderisReadOnly in class AbstractTableDataProviderfieldKey - 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 boolean isRowAvailable(RowKey row)
throws DataProviderException
true if the specified RowKey represents
data elements that are supported by this TableDataProvider;
otherwise, return false
isRowAvailable in interface TableDataProviderisRowAvailable in class AbstractTableDataProviderrow - RowKey specifying row to be tested
true if the row is available, false if
not
DataProviderException - Implementations may wish to surface
internal exceptions (nested in DataProviderException) rather
than simply returning false. Consult the documentation of the
specific TableDataProvider implementation for details on what
exceptions might be wrapped by a DPE.
public void removeRow(RowKey row)
throws DataProviderException
Removes the specified row.
NOTE: The method should only be called after testing the
canRemoveRow(RowKey) method to see if this TableDataProvider
supports removing rows.
removeRow in interface TableDataProviderremoveRow in class AbstractTableDataProviderrow - The desired row key to remove
DataProviderException - Implementations may wish to surface
internal exceptions (nested in DataProviderException). A DPE
may also indicate that this RowKey does not
represent a row provided by this TableDataProvider. Consult
the documentation of the specific TableDataProvider
implementation for details on what exceptions might be wrapped
by a DPE.TableDataProvider.canRemoveRow(RowKey)
public void setValue(FieldKey fieldKey,
RowKey row,
java.lang.Object value)
throws DataProviderException
Sets the value of the data element represented by the specified
FieldKey and RowKey to the specified new value.
setValue in interface TableDataProvidersetValue in class AbstractTableDataProviderfieldKey - FieldKey identifying the data element
whose value is to be modifiedrow - RowKey indentifying the data row whose value
is to be modifiedvalue - New value for this data element
DataProviderException - Implementations may wish to surface
internal exceptions (nested in DataProviderException). A DPE
may also indicate that this FieldKey or
RowKey does not represent a data element provided
by this TableDataProvider. Consult the documentation of the
specific TableDataProvider implementation for details on what
exceptions might be wrapped by a DPE.public void addRefreshableDataListener(RefreshableDataListener listener)
Register a new RefreshableDataListener to this
RefreshableDataProvider instance.
addRefreshableDataListener in interface RefreshableDataProviderlistener - New RefreshableDataListener to registerpublic void removeRefreshableDataListener(RefreshableDataListener listener)
Deregister an existing RefreshableDataListener from
RefreshableDataProvider instance.
removeRefreshableDataListener in interface RefreshableDataProviderlistener - Old RefreshableDataListener to removepublic RefreshableDataListener[] getRefreshableDataListeners()
getRefreshableDataListeners in interface RefreshableDataProviderRefreshableDataListeners
currently registered on this RefreshableDataProvider.
If there are no registered listeners, a zero-length array is
returned.
public void refresh()
throws DataProviderException
Cause a re-fetch of whatever data this DataProvider is
representing from the underlying source. This may result in a JDBC call,
or an EJB or web service method invocation, etc. Any cached changes in
the DataProvider will be lost.
refresh in interface RefreshableDataProviderDataProviderException - 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.
public void commitChanges()
throws DataProviderException
Cause any cached changes to values of data elements supported by this
DataProvider to be passed through to the underlying data
structure.
commitChanges in interface TransactionalDataProviderDataProviderException - 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.
public void revertChanges()
throws DataProviderException
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.
revertChanges in interface TransactionalDataProviderDataProviderException - 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.public void addTransactionalDataListener(TransactionalDataListener listener)
Register a new TransactionalDataListener to this
TransactionalDataProvider instance.
addTransactionalDataListener in interface TransactionalDataProviderlistener - New TransactionalDataListener to registerpublic void removeTransactionalDataListener(TransactionalDataListener listener)
Deregister an existing TransactionalDataListener from
TransactionalDataProvider instance.
removeTransactionalDataListener in interface TransactionalDataProviderlistener - Old TransactionalDataListener to removepublic TransactionalDataListener[] getTransactionalDataListeners()
getTransactionalDataListeners in interface TransactionalDataProviderTransactionalDataListeners
currently registered on this TransactionalDataProvider.
If there are no registered listeners, a zero-length array is
returned.
protected void checkExecute()
throws java.sql.SQLException
Check if rowset, if so, execute if necessary.
java.sql.SQLExceptionprotected void fireChangesCommitted()
Fires a changesCommtted event to each registered TransactionalDataListener.
protected void fireChangesReverted()
Fires a changesReverted event to each registered TransactionalDataListener.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||