com.sun.data.provider.impl
Class FilteredTableDataProvider

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

public class FilteredTableDataProvider
extends AbstractTableDataProvider

Specialized TableDataProvider that is filtered by a specified TableDataFilter.

See Also:
Serialized Form

Field Summary
protected  TableDataFilter filter
           
protected  TableDataProvider provider
           
 
Fields inherited from class com.sun.data.provider.impl.AbstractTableDataProvider
cursorRow, rowKeyList, rowKeyMap, tcListeners
 
Fields inherited from class com.sun.data.provider.impl.AbstractDataProvider
dpListeners, fieldKeys
 
Constructor Summary
FilteredTableDataProvider()
           
 
Method Summary
 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 canAppendRow() method to see if this TableDataProvider supports the append operation.

 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 true. If the data provider is not resizable, or cannot support an append operation, this method should return false.

 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 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)
 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 true. If the data provider is does not support removing rows, this method should return false.

 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.

 FieldKey getFieldKey(java.lang.String fieldId)
          

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

 FieldKey[] getFieldKeys()
          
 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.
 TableDataFilter getTableDataFilter()
           
 TableDataProvider getTableDataProvider()
           
 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 FieldKey and RowKey.

 RowKey insertRow(RowKey beforeRow)
          

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.

 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.

 boolean isRowAvailable(RowKey row)
          Returns true if the specified RowKey represents data elements that are supported by this TableDataProvider; otherwise, return false
 void removeRow(RowKey row)
          

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.

 void setTableDataFilter(TableDataFilter filter)
           
 void setTableDataProvider(TableDataProvider provider)
           
 void setValue(FieldKey fieldKey, RowKey row, 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 class com.sun.data.provider.impl.AbstractTableDataProvider
addTableCursorListener, addTableDataListener, findAll, findAll, findAll, findAll, findFirst, findFirst, findFirst, findFirst, fireCursorChanged, fireCursorChanging, fireRowAdded, fireRowRemoved, fireValueChanged, getAllRows, getCursorIndex, getCursorRow, getTableCursorListeners, getTableDataListeners, getValue, getValue, removeTableCursorListener, removeTableDataListener, setCursorIndex, setCursorRow, 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.DataProvider
addDataListener, getDataListeners, removeDataListener
 

Field Detail

provider

protected TableDataProvider provider

filter

protected TableDataFilter filter
Constructor Detail

FilteredTableDataProvider

public FilteredTableDataProvider()
Method Detail

setTableDataProvider

public void setTableDataProvider(TableDataProvider provider)
Parameters:
provider - TableDataProvider

getTableDataProvider

public TableDataProvider getTableDataProvider()
Returns:
TableDataProvider

setTableDataFilter

public void setTableDataFilter(TableDataFilter filter)
Parameters:
filter - TableDataFilter

getTableDataFilter

public TableDataFilter getTableDataFilter()
Returns:
TableDataFilter

getFieldKeys

public FieldKey[] getFieldKeys()
                        throws DataProviderException
Description copied from class: AbstractDataProvider

Specified by:
getFieldKeys in interface DataProvider
Overrides:
getFieldKeys in class AbstractDataProvider
Returns:
FieldKey[]
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
Description copied from class: AbstractDataProvider

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 - String
Returns:
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 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

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 AbstractTableDataProvider
Parameters:
fieldKey - FieldKey identifying the data element whose type is to be returned
Returns:
the data type of the data element referenced by the specified data key
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 AbstractTableDataProvider
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.

getRowCount

public int getRowCount()
                throws DataProviderException

Specified by:
getRowCount in interface TableDataProvider
Specified by:
getRowCount in class AbstractTableDataProvider
Returns:
the number of rows represented by this TableDataProvider if this information is available; otherwise, return -1 (indicating unknown row count)
Throws:
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.

getRowKeys

public RowKey[] getRowKeys(int count,
                           RowKey afterRow)
                    throws DataProviderException
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.

Specified by:
getRowKeys in interface TableDataProvider
Overrides:
getRowKeys in class AbstractTableDataProvider
Parameters:
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.
Returns:
An array of RowKey objects representing the requested batch of rows.
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 TableDataProvider implementation for details on what exceptions might be wrapped by a DPE.

getRowKey

public RowKey getRowKey(java.lang.String rowId)
                 throws DataProviderException
Returns a RowKey for the specified rowId. This allows a RowKey to be stored off as a simple string, which can be resolved into an instance of a RowKey at a later date.

Specified by:
getRowKey in interface TableDataProvider
Overrides:
getRowKey in class AbstractTableDataProvider
Parameters:
rowId - The cannoncial string ID of the desired RowKey
Returns:
A RowKey object representing the desired row, or null if the specified rowId does not correspond to a row in this TableDataProvider
Throws:
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.

isRowAvailable

public boolean isRowAvailable(RowKey row)
                       throws DataProviderException
Returns true if the specified RowKey represents data elements that are supported by this TableDataProvider; otherwise, return false

Specified by:
isRowAvailable in interface TableDataProvider
Overrides:
isRowAvailable in class AbstractTableDataProvider
Parameters:
row - RowKey specifying row to be tested
Returns:
true if the row is available, false if not
Throws:
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.

getValue

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

Return value of the data element referenced by the specified FieldKey and RowKey.

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

setValue

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.

Specified by:
setValue in interface TableDataProvider
Specified by:
setValue in class AbstractTableDataProvider
Parameters:
fieldKey - FieldKey identifying the data element whose value is to be modified
row - RowKey indentifying the data row 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). 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.

canInsertRow

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:

Specified by:
canInsertRow in interface TableDataProvider
Specified by:
canInsertRow in class AbstractTableDataProvider
Parameters:
beforeRow - The desired location to insert the new row in front of
Returns:
true if the data provider is resizable, or false if not.
Throws:
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.
See Also:
TableDataProvider.insertRow(RowKey)

insertRow

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.

Specified by:
insertRow in interface TableDataProvider
Specified by:
insertRow in class AbstractTableDataProvider
Parameters:
beforeRow - The desired location to insert the new row in front of
Returns:
A RowKey representing the address of the newly inserted row
Throws:
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.
See Also:
TableDataProvider.canInsertRow(RowKey)

canAppendRow

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.

Specified by:
canAppendRow in interface TableDataProvider
Specified by:
canAppendRow in class AbstractTableDataProvider
Returns:
true if the data provider supports the append operation, or false if not.
Throws:
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.
See Also:
TableDataProvider.appendRow()

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.

Specified by:
appendRow in interface TableDataProvider
Specified by:
appendRow in class AbstractTableDataProvider
Returns:
The row key for the newly appended row
Throws:
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.
See Also:
TableDataProvider.canAppendRow()

canRemoveRow

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.

Specified by:
canRemoveRow in interface TableDataProvider
Specified by:
canRemoveRow in class AbstractTableDataProvider
Parameters:
row - The desired row to remove
Returns:
true if the data provider supports removing rows, or false if not.
Throws:
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.
See Also:
TableDataProvider.removeRow(RowKey)

removeRow

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.

Specified by:
removeRow in interface TableDataProvider
Specified by:
removeRow in class AbstractTableDataProvider
Parameters:
row - The desired row key to remove
Throws:
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.
See Also:
TableDataProvider.canRemoveRow(RowKey)

cursorFirst

public boolean cursorFirst()
                    throws DataProviderException

Move the cursor to the first row in this TableDataProvider.

Specified by:
cursorFirst in interface TableDataProvider
Overrides:
cursorFirst in class AbstractTableDataProvider
Returns:
true if the cursor row was successfully changed; else false
Throws:
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.

cursorPrevious

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.

Specified by:
cursorPrevious in interface TableDataProvider
Overrides:
cursorPrevious in class AbstractTableDataProvider
Returns:
true if the cursor row was successfully changed; else false
Throws:
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.

cursorNext

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.

Specified by:
cursorNext in interface TableDataProvider
Overrides:
cursorNext in class AbstractTableDataProvider
Returns:
true if the cursor row was successfully changed; else false
Throws:
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.

cursorLast

public boolean cursorLast()
                   throws DataProviderException

Move the cursor to the last row in this TableDataProvider.

Specified by:
cursorLast in interface TableDataProvider
Overrides:
cursorLast in class AbstractTableDataProvider
Returns:
true if the cursor row was successfully changed; else false
Throws:
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.