|
||||||||||
| 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.ObjectListDataProvider
public class ObjectListDataProvider
This TableDataProvider wraps access to a
list of Java Objects. The FieldKeys correspond to the JavaBean
properties and optionally the public member fields of the Java Object.
This class implements TransactionalDataProvider semantics,
meaning that all updates to existing fields, as well as inserted and
deleted rows, are cached until commitChanges() is called.
Once that call is made, any RowKey you have retrieved from
this instance is invalid, and must be reacquired.
WARNING - Until you call setList() or
setObjectType() with a non-null parameter, or use a constructor
variant that accepts an non-null non-empty list, no information about field keys will
be available. Therefore, any attempt to reference a FieldKey
or field identifier in a method call will throw
IllegalArgumentException.
NOTE about Serializable: This class wraps access to a list of any Java
Objects. The Objects can be swapped out using the setObject(Object)
method. For this class to remain Serializable, the contained Objects must
also be Serializable.
| Field Summary |
|---|
| 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 | |
|---|---|
ObjectListDataProvider()
Construct a new ObjectListDataProvider with no known object type. |
|
ObjectListDataProvider(java.lang.Class objectType)
Constructs a new ObjectListDataProvider for the specified object type. |
|
ObjectListDataProvider(java.lang.Class objectType,
boolean includeFields)
Constructs a new ObjectListDataProvider for the specified object type and includeFields property value. |
|
ObjectListDataProvider(java.util.List list)
Constructs a new ObjectListDataProvider wrapping the specified list. |
|
ObjectListDataProvider(java.util.List list,
boolean includeFields)
Constructs a new ObjectListDataProvider wrapping the specified list with the specified include fields flag. |
|
| Method Summary | |
|---|---|
void |
addObject(java.lang.Object object)
Append the specified object to the list of contained objects. |
void |
addTransactionalDataListener(TransactionalDataListener listener)
Register a new |
RowKey |
appendRow()
Construct a new instance of the specified object type and append it to the end of the list. |
RowKey |
appendRow(java.lang.Object object)
Append the specified object to the end of the list. |
boolean |
canAppendRow()
Return true if the userResizable property is set to
true, and there is a public zero-args constructor for the
class specified by the objectType property. |
boolean |
canInsertRow(RowKey beforeRow)
Return true if the userResizable property is set to
true, and there is a public zero-args constructor for the
class specified by the objectType property. |
boolean |
canRemoveRow(RowKey row)
Return true if the userResizable
property is set to true. |
void |
clearObjectList()
Clear the list of contained objects. |
void |
commitChanges()
Cause any cached updates to existing field values, as well as inserted and deleted rows, to be flowed through to the underlying List wrapped by this
DataProvider. |
FieldKey |
getFieldKey(java.lang.String fieldId)
Returns the |
FieldKey[] |
getFieldKeys()
|
java.util.List |
getList()
Return the |
java.lang.Object |
getObject(RowKey row)
Returns the object stored at the specified row. |
java.lang.Object[] |
getObjects()
Return the contained objects as an array. |
java.lang.Class |
getObjectType()
Return the object type that this data provider contains. |
int |
getRowCount()
|
TransactionalDataListener[] |
getTransactionalDataListeners()
|
java.lang.Class |
getType(FieldKey fieldKey)
Returns the data type of the data element referenced by the specified data key. |
java.lang.Object |
getValue(FieldKey fieldKey)
Returns value of the data element referenced by the specified
|
java.lang.Object |
getValue(FieldKey fieldKey,
RowKey rowKey)
Return value of the data element referenced by the specified
|
RowKey |
insertRow(RowKey beforeRow)
Construct a new instance of the specified object type and insert it at the specified position in the list. |
boolean |
isIncludeFields()
Return the state of the includeFields property. |
boolean |
isReadOnly(FieldKey fieldKey)
Return a flag indicating whether the value of the data element
represented by the specified |
boolean |
isRemoved(RowKey row)
Return true if the specified row has been
marked for removal on the next call to commitChanges(). |
boolean |
isRowAvailable(RowKey row)
Return true if the specified RowKey represents
a row in the original list, or a row that has been appended. |
boolean |
isUserResizable()
Return the current state of the userResizable property. |
void |
removeObject(java.lang.Object object)
Remove the specified object from the list of contained objects. |
void |
removeObject(RowKey row)
Remove the object at the specified row from the list of contained objects. |
void |
removeRow(RowKey row)
Remove the object at the specified row from the list. |
void |
removeTransactionalDataListener(TransactionalDataListener listener)
Deregister an existing |
void |
revertChanges()
Cause any cached changes to values of data elements supported by this
|
void |
setIncludeFields(boolean includeFields)
Set the includeFields property. |
void |
setList(java.util.List list)
Replace the List that we are wrapping. |
void |
setObject(RowKey row,
java.lang.Object object)
Replace the object at the specified row. |
void |
setObjectType(java.lang.Class objectType)
Set the object type contained in this ObjectListDataProvider. |
void |
setUserResizable(boolean resizable)
Set the user resizable property. |
void |
setValue(FieldKey fieldKey,
java.lang.Object value)
Set the value of the data element represented by the specified
|
void |
setValue(FieldKey fieldKey,
RowKey rowKey,
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, cursorFirst, cursorLast, cursorNext, cursorPrevious, findAll, findAll, findAll, findAll, findFirst, findFirst, findFirst, findFirst, fireCursorChanged, fireCursorChanging, fireRowAdded, fireRowRemoved, fireValueChanged, getAllRows, getCursorIndex, getCursorRow, getRowKey, getRowKeys, getTableCursorListeners, getTableDataListeners, getValue, removeTableCursorListener, removeTableDataListener, setCursorIndex, setCursorRow, 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 |
| Constructor Detail |
|---|
public ObjectListDataProvider()
Construct a new ObjectListDataProvider with no known object type. The
setObjectType() method can be used to set the object type.
If not set, the first added object will automatically define the object
type.
public ObjectListDataProvider(java.util.List list)
Constructs a new ObjectListDataProvider wrapping the specified list.
list - List to be wrapped
public ObjectListDataProvider(java.util.List list,
boolean includeFields)
Constructs a new ObjectListDataProvider wrapping the specified list with the specified include fields flag.
list - List to be wrappedincludeFields - Desired include fields property settingpublic ObjectListDataProvider(java.lang.Class objectType)
Constructs a new ObjectListDataProvider for the specified object type.
objectType - Desired object type Class
public ObjectListDataProvider(java.lang.Class objectType,
boolean includeFields)
Constructs a new ObjectListDataProvider for the specified object type
and includeFields property value.
objectType - Desired object type ClassincludeFields - Desired include fields property setting| Method Detail |
|---|
public boolean isIncludeFields()
Return the state of the includeFields property.
public void setIncludeFields(boolean includeFields)
Set the includeFields property. This affects the set of
FieldKeys that this DataProvider
emits. If the property is set to true (the default), then
public fields will be included in the list of available keys (intermixed
with the public properties). Otherwise, only the public properties will
be available.
includeFields - The new include fields valuepublic java.util.List getList()
Return the List that we are wrapping.
public void setList(java.util.List list)
Replace the List that we are wrapping. In addition,
the objectType property will be reset based on the
class of the first element in the list (if any). If the list is
empty, objectType will be set to null.
list - The new list to be wrappedpublic java.lang.Class getObjectType()
Return the object type that this data provider contains. This
determines the list of FieldKeys that this provider supplies.
public void setObjectType(java.lang.Class objectType)
Set the object type contained in this ObjectListDataProvider. This
type determines the list of public properties and fields to expose as
FieldKeys. If no object type is specified, the first added
object's class will be used as the object type.
objectType - The desired Class type to be contained in this
ObjectDataProviderpublic boolean isUserResizable()
Return the current state of the userResizable property. Note that
the wrapped list will not be actually resizable unless there is a
public no-args constructor on the objectType class.
public void setUserResizable(boolean resizable)
Set the user resizable property. If set to true (the
default), the resizability of this ObjectListDataProvider is based on
wether or not a public default constructor exists in the object type.
If the userResizable propert is set to false, then this
ObjectListDataProvider will not be resizable, regardless of the existence
of a public default constructor on the object type.
resizable - true to make this ObjectListDataProvider
resizable, pending the existence of a public default constructor
on the contained object type, or false to make it
non-resizable.TableDataProvider.canInsertRow(RowKey beforeRow)public void addObject(java.lang.Object object)
Append the specified object to the list of contained objects.
object - The Object to store in the listpublic void clearObjectList()
Clear the list of contained objects.
public java.lang.Object getObject(RowKey row)
Returns the object stored at the specified row.
row - The desired row to retrieve the contained object frompublic java.lang.Object[] getObjects()
Return the contained objects as an array.
public boolean isRemoved(RowKey row)
Return true if the specified row has been
marked for removal on the next call to commitChanges().
row - The RowKey of the row to checkpublic void removeObject(java.lang.Object object)
Remove the specified object from the list of contained objects.
object - The Object to remove from the listpublic void removeObject(RowKey row)
Remove the object at the specified row from the list of contained objects.
row - The desired Object row to remove from the list
public void setObject(RowKey row,
java.lang.Object object)
Replace the object at the specified row.
row - The desired row to set the contained objectobject - The new object to set at the specified row
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 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 AbstractTableDataProviderfieldKey - 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 AbstractTableDataProviderfieldKey - 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 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 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 rowKey)
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 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 boolean isRowAvailable(RowKey row)
throws DataProviderException
Return true if the specified RowKey represents
a row in the original list, or a row that has been appended. FIXME -
deal with RowKeys for inserted rows too, when inserts are
supported.
isRowAvailable in interface TableDataProviderisRowAvailable in class AbstractTableDataProviderrow - RowKey to test for availability
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 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.
setValue in interface TableDataProvidersetValue in class AbstractTableDataProviderfieldKey - 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 canAppendRow()
throws DataProviderException
Return true if the userResizable property is set to
true, and there is a public zero-args constructor for the
class specified by the objectType property.
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 RowKey appendRow()
throws DataProviderException
Construct a new instance of the specified object type and append it to the end of the list.
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 RowKey appendRow(java.lang.Object object)
throws DataProviderException
Append the specified object to the end of the list.
object - Object to be appended
DataProviderException
public boolean canInsertRow(RowKey beforeRow)
throws DataProviderException
Return true if the userResizable property is set to
true, and there is a public zero-args constructor for the
class specified by the objectType property.
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 RowKey insertRow(RowKey beforeRow)
throws DataProviderException
Construct a new instance of the specified object type and insert it at the specified position in the list.
insertRow in interface TableDataProviderinsertRow in class AbstractTableDataProviderbeforeRow - Row before which to insert the new row
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 canRemoveRow(RowKey row)
throws DataProviderException
Return true if the userResizable
property is set to true.
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 void removeRow(RowKey row)
throws DataProviderException
Remove the object at the specified row from the list.
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 commitChanges()
throws DataProviderException
Cause any cached updates to existing field values, as well as
inserted and deleted rows, to be flowed through to the underlying
List wrapped by this
DataProvider.
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 TransactionalDataListener[] getTransactionalDataListeners()
getTransactionalDataListeners in interface TransactionalDataProviderTransactionalDataListeners
currently registered on this TransactionalDataProvider.
If there are no registered listeners, a zero-length array is
returned.public void removeTransactionalDataListener(TransactionalDataListener listener)
Deregister an existing TransactionalDataListener from
TransactionalDataProvider instance.
removeTransactionalDataListener in interface TransactionalDataProviderlistener - Old TransactionalDataListener to remove
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||