|
||||||||||
| 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
public abstract class AbstractTableDataProvider
Abstract base implementation of TableDataProvider. This class is a
convenient base class to use when creating a new TableDataProvider
implementation.
| Field Summary | |
|---|---|
protected RowKey |
cursorRow
storage for the current cursor row |
protected java.util.ArrayList |
rowKeyList
|
protected java.util.HashMap |
rowKeyMap
|
protected TableCursorListener[] |
tcListeners
Array of TableCursorListener instances registered for
this TableDataProvider. |
| Fields inherited from class com.sun.data.provider.impl.AbstractDataProvider |
|---|
dpListeners, fieldKeys |
| Constructor Summary | |
|---|---|
AbstractTableDataProvider()
|
|
| Method Summary | |
|---|---|
void |
addTableCursorListener(TableCursorListener listener)
Register a new |
void |
addTableDataListener(TableDataListener l)
Register a new |
abstract RowKey |
appendRow()
Appends a new row at the end of the list and returns the row key for the newly appended row. |
abstract boolean |
canAppendRow()
This method is called to test if this TableDataProvider supports the append operation. |
abstract boolean |
canInsertRow(RowKey beforeRow)
This method is called to test if this TableDataProvider supports resizability. |
abstract boolean |
canRemoveRow(RowKey row)
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 |
boolean |
cursorPrevious()
Move the cursor to the row before the current cursor row, unless the cursor is currently at the first row. |
RowKey[] |
findAll(FieldKey[] fieldKeys,
java.lang.Object[] values)
Finds all rows with the specified values stored under the specified field keys. |
RowKey[] |
findAll(FieldKey fieldKey,
java.lang.Object value)
Finds all rows with the specified value stored under the specified field key. |
RowKey[] |
findAll(java.lang.String[] fieldIds,
java.lang.Object[] values)
|
RowKey[] |
findAll(java.lang.String fieldId,
java.lang.Object value)
|
RowKey |
findFirst(FieldKey[] fieldKeys,
java.lang.Object[] values)
Finds the first row with the specified values stored under the specified field keys. |
RowKey |
findFirst(FieldKey fieldKey,
java.lang.Object value)
Finds the first row with the specified value stored under the specified field key. |
RowKey |
findFirst(java.lang.String[] fieldIds,
java.lang.Object[] values)
|
RowKey |
findFirst(java.lang.String fieldId,
java.lang.Object value)
|
protected void |
fireCursorChanged(RowKey oldRow,
RowKey newRow)
Fires a cursorChanged event to all registered TableCursorListeners |
protected void |
fireCursorChanging(RowKey oldRow,
RowKey newRow)
Fires a cursorChanging event to all registered TableCursorListeners. |
protected void |
fireRowAdded(RowKey newRow)
Fires a rowAdded event to all registered TableDataListeners |
protected void |
fireRowRemoved(RowKey oldRow)
Fires a rowRemoved event to all registered TableDataListeners |
protected void |
fireValueChanged(FieldKey fieldKey,
RowKey row,
java.lang.Object oldValue,
java.lang.Object newValue)
Fires a valueChanged event to all registered TableDataListeners |
RowKey[] |
getAllRows()
Returns all the RowKeys, which may force the underlying dataprovider to go and perform an expensive operation to fetch them. |
protected int |
getCursorIndex()
|
RowKey |
getCursorRow()
|
abstract 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()
|
abstract 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
|
abstract java.lang.Object |
getValue(FieldKey fieldKey,
RowKey row)
Return value of the data element referenced by the specified
|
java.lang.Object |
getValue(java.lang.String fieldId,
RowKey row)
|
abstract RowKey |
insertRow(RowKey beforeRow)
Inserts a new row at the specified row. |
abstract 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 |
abstract void |
removeRow(RowKey row)
Removes the specified row. |
void |
removeTableCursorListener(TableCursorListener listener)
Deregister an existing |
void |
removeTableDataListener(TableDataListener l)
Deregister an existing |
protected boolean |
setCursorIndex(int index)
|
void |
setCursorRow(RowKey row)
Sets the cursor to the row represented by the passed |
void |
setValue(FieldKey fieldKey,
java.lang.Object value)
Set the value of the data element represented by the specified
|
abstract void |
setValue(FieldKey fieldKey,
RowKey row,
java.lang.Object value)
Sets the value of the data element represented by the specified
|
void |
setValue(java.lang.String fieldId,
RowKey row,
java.lang.Object value)
|
| Methods inherited from class com.sun.data.provider.impl.AbstractDataProvider |
|---|
addDataListener, addFieldKey, addFieldKeys, clearFieldKeys, fireProviderChanged, fireValueChanged, getDataListeners, getFakeData, getFakeData, getFieldKey, getFieldKeys, 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, getFieldKey, getFieldKeys, removeDataListener |
| Field Detail |
|---|
protected java.util.ArrayList rowKeyList
protected java.util.HashMap rowKeyMap
protected RowKey cursorRow
protected TableCursorListener[] tcListeners
Array of TableCursorListener instances registered for
this TableDataProvider.
| Constructor Detail |
|---|
public AbstractTableDataProvider()
| 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 DataProvidergetType in class AbstractDataProviderfieldKey - 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 DataProviderisReadOnly in class AbstractDataProviderfieldKey - 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 int getRowCount()
throws DataProviderException
getRowCount in interface TableDataProviderTableDataProvider 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 abstract 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 TableDataProviderfieldKey - 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 abstract 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 TableDataProviderfieldKey - 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 abstract 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 TableDataProviderbeforeRow - 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 abstract 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 TableDataProviderbeforeRow - 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 abstract 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 TableDataProvidertrue 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 abstract 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 TableDataProviderDataProviderException - 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 abstract 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 TableDataProviderrow - 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 abstract 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 TableDataProviderrow - 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 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 TableDataProvidercount - 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
TableDataProvider
getRowKey in interface TableDataProviderrowId - 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 row)
throws DataProviderException
true if the specified RowKey represents
data elements that are supported by this TableDataProvider;
otherwise, return false
isRowAvailable in interface TableDataProviderrow - 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(java.lang.String fieldId,
RowKey row)
throws DataProviderException
DataProviderExceptiongetValue(FieldKey, RowKey)
public void setValue(java.lang.String fieldId,
RowKey row,
java.lang.Object value)
throws DataProviderException
DataProviderExceptionsetValue(FieldKey, RowKey, Object)
public RowKey findFirst(java.lang.String fieldId,
java.lang.Object value)
throws DataProviderException
DataProviderExceptionfindFirst(FieldKey, Object)
public RowKey findFirst(java.lang.String[] fieldIds,
java.lang.Object[] values)
throws DataProviderException
DataProviderExceptionfindFirst(FieldKey[], Object[])
public RowKey[] findAll(java.lang.String fieldId,
java.lang.Object value)
throws DataProviderException
DataProviderExceptionfindAll(FieldKey, Object)
public RowKey[] findAll(java.lang.String[] fieldIds,
java.lang.Object[] values)
throws DataProviderException
DataProviderExceptionfindAll(FieldKey[], Object[])
public RowKey[] getAllRows()
throws DataProviderException
DataProviderException
public RowKey findFirst(FieldKey fieldKey,
java.lang.Object value)
throws DataProviderException
fieldKey - FieldKeyvalue - Object
DataProviderException
public RowKey findFirst(FieldKey[] fieldKeys,
java.lang.Object[] values)
throws DataProviderException
fieldKeys - FieldKey[]values - Object[]
DataProviderException
public RowKey[] findAll(FieldKey fieldKey,
java.lang.Object value)
throws DataProviderException
fieldKey - FieldKeyvalue - Object
DataProviderException
public RowKey[] findAll(FieldKey[] fieldKeys,
java.lang.Object[] values)
throws DataProviderException
fieldKeys - FieldKey[]values - Object[]
DataProviderExceptionprotected int getCursorIndex()
protected boolean setCursorIndex(int index)
public RowKey getCursorRow()
throws DataProviderException
getCursorRow in interface TableDataProviderRowKey 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 TableDataProviderrow - 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 TableDataProvidertrue 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 TableDataProvidertrue 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 TableDataProvidertrue 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 TableDataProvidertrue 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 java.lang.Object getValue(FieldKey fieldKey)
throws DataProviderException
Returns value of the data element referenced by the specified
FieldKey.
getValue in interface DataProvidergetValue in class AbstractDataProviderfieldKey - 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 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 DataProvidersetValue in class AbstractDataProviderfieldKey - 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 void addTableDataListener(TableDataListener l)
Register a new TableDataListener to this TableDataProvider
instance.
addTableDataListener in interface TableDataProviderl - New TableDataListener to registerpublic void removeTableDataListener(TableDataListener l)
Deregister an existing TableDataListener from this
TableDataProvider instance.
removeTableDataListener in interface TableDataProviderl - Old TableDataListener to deregisterpublic TableDataListener[] getTableDataListeners()
getTableDataListeners in interface TableDataProviderTableDataListeners currently registered
on this TableDataProvider. If there are no registered listeners,
a zero-length array is returned.public void addTableCursorListener(TableCursorListener listener)
Register a new TableCursorListener to this TableDataProvider
instance.
addTableCursorListener in interface TableDataProviderlistener - New TableCursorListener to registerpublic void removeTableCursorListener(TableCursorListener listener)
Deregister an existing TableCursorListener from this
TableDataProvider instance.
removeTableCursorListener in interface TableDataProviderlistener - Old TableCursorListener to deregisterpublic TableCursorListener[] getTableCursorListeners()
getTableCursorListeners in interface TableDataProviderTableCursorListeners currently registered
on this TableDataProvider. If there are no registered listeners,
a zero-length array is returned.
protected void fireValueChanged(FieldKey fieldKey,
RowKey row,
java.lang.Object oldValue,
java.lang.Object newValue)
TableDataListeners
row - The row of the value changefieldKey - The FieldKey of the value changeoldValue - The old value (before the value change)newValue - The new value (after the value change)protected void fireRowAdded(RowKey newRow)
TableDataListeners
newRow - The newly added rowprotected void fireRowRemoved(RowKey oldRow)
TableDataListeners
oldRow - The removed row
protected void fireCursorChanging(RowKey oldRow,
RowKey newRow)
throws TableCursorVetoException
TableCursorListeners. If a TableCursorVetoException is thrown by any
listeners, the cursor will not be changed.
oldRow - The old cursor row (before the cursor change)newRow - The new cursor row (after the cursor change)
TableCursorVetoException - This method may throw a
TableCursorVetoException if one of registered listeners throws
an exception. This will prevent the cursor move from occurring.
protected void fireCursorChanged(RowKey oldRow,
RowKey newRow)
TableCursorListeners
oldRow - The old cursor row (before the cursor change)newRow - The new cursor row (after the cursor change)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||