|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.data.provider.impl.AbstractDataProvider com.sun.data.provider.impl.AbstractTableDataProvider com.sun.data.provider.impl.ObjectListDataProvider
This TableDataProvider
wraps access to a
list of Java Objects. The FieldKey
s 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 wrappedpublic 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 Classpublic 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 settingMethod 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
FieldKey
s 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 FieldKey
s 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
FieldKey
s. 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 listpublic 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 rowpublic 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 DataProvider
getFieldKey
in class AbstractDataProvider
DataProviderException
public FieldKey[] getFieldKeys() throws DataProviderException
getFieldKeys
in interface DataProvider
getFieldKeys
in class AbstractDataProvider
DataProviderException
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 DataProvider
getType
in class AbstractTableDataProvider
DataProviderException
public java.lang.Object getValue(FieldKey fieldKey) throws DataProviderException
Returns value of the data element referenced by the specified
FieldKey
.
getValue
in interface DataProvider
getValue
in class AbstractTableDataProvider
DataProviderException
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 DataProvider
setValue
in class AbstractTableDataProvider
DataProviderException
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 DataProvider
isReadOnly
in class AbstractTableDataProvider
DataProviderException
public int getRowCount() throws DataProviderException
getRowCount
in interface TableDataProvider
getRowCount
in class AbstractTableDataProvider
DataProviderException
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 TableDataProvider
getValue
in class AbstractTableDataProvider
DataProviderException
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 RowKey
s for inserted rows too, when inserts are
supported.
isRowAvailable
in interface TableDataProvider
isRowAvailable
in class AbstractTableDataProvider
row
- RowKey
to test for availability
DataProviderException
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 TableDataProvider
setValue
in class AbstractTableDataProvider
DataProviderException
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 TableDataProvider
canAppendRow
in class AbstractTableDataProvider
DataProviderException
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 TableDataProvider
appendRow
in class AbstractTableDataProvider
DataProviderException
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 TableDataProvider
canInsertRow
in class AbstractTableDataProvider
DataProviderException
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 TableDataProvider
insertRow
in class AbstractTableDataProvider
beforeRow
- Row before which to insert the new row
DataProviderException
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 TableDataProvider
canRemoveRow
in class AbstractTableDataProvider
DataProviderException
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 TableDataProvider
removeRow
in class AbstractTableDataProvider
DataProviderException
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 TransactionalDataProvider
DataProviderException
- 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 TransactionalDataProvider
DataProviderException
- 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 TransactionalDataProvider
listener
- New TransactionalDataListener
to registerpublic TransactionalDataListener[] getTransactionalDataListeners()
getTransactionalDataListeners
in interface TransactionalDataProvider
TransactionalDataListener
s
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 TransactionalDataProvider
listener
- Old TransactionalDataListener
to remove
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |