|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
TableDataProvider is a specialized subinterface of DataProvider
that provides access to a scrollable set of "rows" of data elements, with
each row being identified by a RowKey
. Access to the underlying
data elements may be done in a random fashion by using the methods defined
in this interface, or you can set the cursor row and use the
getType()
, getValue()
, isReadOnly()
,
and setValue()
methods from the base DataProvider
interface to access data elements for the cursor row specified by calling
setCursorRow(RowKey)
.
The set of FieldKey
s returned by getFieldKeys()
MUST be available on every row supported by this
TableDataProvider
. This implies a rectangular (matrix) dataset.
The set of RowKey
s returned by getRowKeys(...)
are
expected to uniquely represent the rows contained in the underlying data
source. The RowKey objects should remain valid as long as the set of rows
in the TableDataProvider has not been re-fetched. Once a re-fetch has
happened (by whatever means are supplied by specific TableDataProvider
implementations), the previously fetched RowKeys may become invalid. Consult
the documentation of the specific TableDataProvider implementation for
details on the expected valid lifespan of a RowKey.
Most methods throw DataProviderException
, which is a generic
runtime exception indicating something is amiss in the internal state of the
TableDataProvider implementation. Because DPE is a runtime exception, method
calls are not required to be wrapped in a try...catch block, but it is
advised to check the documentation of the particular TableDataProvider
implementation to see what conditions will cause a DataProviderException to
be thrown. It is recommended to always wrap calls to this interface in
try...catch blocks in case an unforseen error condition arises at runtime.
Method Summary | |
void |
addTableCursorListener(TableCursorListener listener)
Register a new TableCursorListener to this TableDataProvider
instance. |
void |
addTableDataListener(TableDataListener listener)
Register a new TableDataListener to this TableDataProvider
instance. |
RowKey |
appendRow()
Appends a new row at the end of the list and returns the row key for the newly appended row. |
boolean |
canAppendRow()
This method is called to test if this TableDataProvider supports the append operation. |
boolean |
canInsertRow(RowKey beforeRow)
This method is called to test if this TableDataProvider supports resizability. |
boolean |
canRemoveRow(RowKey rowKey)
This method is called to test if this TableDataProvider supports the removeRow operation. |
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 TableDataProvider . |
boolean |
cursorPrevious()
Move the cursor to the row before the current cursor row, unless the cursor is currently at the first row. |
RowKey |
getCursorRow()
|
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. |
TableCursorListener[] |
getTableCursorListeners()
|
TableDataListener[] |
getTableDataListeners()
|
java.lang.Object |
getValue(FieldKey fieldKey,
RowKey rowKey)
Return value of the data element referenced by the specified FieldKey and RowKey . |
RowKey |
insertRow(RowKey beforeRow)
Inserts a new row at the specified row. |
boolean |
isRowAvailable(RowKey rowKey)
Returns true if the specified RowKey represents
data elements that are supported by this TableDataProvider ;
otherwise, return false |
void |
removeRow(RowKey rowKey)
Removes the specified row. |
void |
removeTableCursorListener(TableCursorListener listener)
Deregister an existing TableCursorListener from this
TableDataProvider instance. |
void |
removeTableDataListener(TableDataListener listener)
Deregister an existing TableDataListener from this
TableDataProvider instance. |
void |
setCursorRow(RowKey rowKey)
Sets the cursor to the row represented by the passed RowKey . |
void |
setValue(FieldKey fieldKey,
RowKey rowKey,
java.lang.Object value)
Sets the value of the data element represented by the specified FieldKey and RowKey to the specified new value. |
Methods inherited from interface com.sun.data.provider.DataProvider |
addDataListener, getDataListeners, getFieldKey, getFieldKeys, getType, getValue, isReadOnly, removeDataListener, setValue |
Method Detail |
public int getRowCount() throws DataProviderException
TableDataProvider
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 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.
count
- 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 getRowKey(java.lang.String rowId) throws DataProviderException
rowId
- 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.public boolean isRowAvailable(RowKey rowKey) throws DataProviderException
true
if the specified RowKey
represents
data elements that are supported by this TableDataProvider
;
otherwise, return false
rowKey
- 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 java.lang.Object getValue(FieldKey fieldKey, RowKey rowKey) throws DataProviderException
Return value of the data element referenced by the specified
FieldKey
and RowKey
.
fieldKey
- FieldKey
identifying the data element
whose value is to be returnedrowKey
- 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 void setValue(FieldKey fieldKey, RowKey rowKey, 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.
fieldKey
- FieldKey
identifying the data element
whose value is to be modifiedrowKey
- 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 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)
beforeRow
- 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.insertRow(RowKey)
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.
beforeRow
- 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.canInsertRow(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
.
true
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.appendRow()
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.
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.canAppendRow()
public boolean canRemoveRow(RowKey rowKey) 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
.
rowKey
- 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.removeRow(RowKey)
public void removeRow(RowKey rowKey) 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.
rowKey
- 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.canRemoveRow(RowKey)
public void addTableDataListener(TableDataListener listener)
Register a new TableDataListener
to this TableDataProvider
instance.
listener
- New TableDataListener
to registerpublic void removeTableDataListener(TableDataListener listener)
Deregister an existing TableDataListener
from this
TableDataProvider instance.
listener
- Old TableDataListener
to deregisterpublic TableDataListener[] getTableDataListeners()
TableDataListener
s currently registered
on this TableDataProvider. If there are no registered listeners,
a zero-length array is returned.public RowKey getCursorRow() throws DataProviderException
RowKey
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 rowKey) throws TableCursorVetoException
Sets the cursor to the row represented by the passed RowKey
.
rowKey
- New RowKey
to move the cursor to.
TableCursorVetoException
- if a TableCursorListener decides to
veto the cursor navigation
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.public boolean cursorFirst() throws DataProviderException
Move the cursor to the first row in this TableDataProvider.
true
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.
true
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
.
true
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.
true
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 void addTableCursorListener(TableCursorListener listener)
Register a new TableCursorListener
to this TableDataProvider
instance.
listener
- New TableCursorListener
to registerpublic void removeTableCursorListener(TableCursorListener listener)
Deregister an existing TableCursorListener
from this
TableDataProvider instance.
listener
- Old TableCursorListener
to deregisterpublic TableCursorListener[] getTableCursorListeners()
TableCursorListener
s currently registered
on this TableDataProvider. If there are no registered listeners,
a zero-length array is returned.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |