|
||||||||||
| 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.ObjectArrayDataProvider
public class ObjectArrayDataProvider
This TableDataProvider wraps access to an
array of Java Objects. The FieldKeys correspond to the JavaBean
properties and optionally the public member fields of the Java Objects.
Note that this TableDataProvider determines which fields are
available by examining the underlying component data type of the array.
If you pass in an array that is of type Object[], then, perhaps
with initialization code like this:
Map map = ...; return new ObjectArrayDataProvider(map.values().toArray());
the fields of your actual object type will not be available. If you know that your data is all of type Foo, do this instead:
Map map = ...;
return new ObjectArrayDataProvider
((Foo[]) map.values().toArray(new Foo[0]));
Since this TableDataProvider wraps an array, and arrays in Java
are not intrinsically resizeable, this implementation will return
false for any call to canAppendRow(),
canInsertRow(), or canRemoveRow(). It will
throw UnsupportedOperationException if you attempt to call
appendRow(), insertRow(), or
removeRow().
WARNING - Until you call setArray() or
setObjectType() with a non-null parameter, or use a constructor
variant that accepts an non-null array, 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 an array of any Java Objects. 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 | |
|---|---|
ObjectArrayDataProvider()
Construct a new ObjectArrayDataProvider with no known data. |
|
ObjectArrayDataProvider(java.lang.Object[] array)
Constructs a new ObjectArraytDataProvider wrapping the specified array. |
|
ObjectArrayDataProvider(java.lang.Object[] array,
boolean includeFields)
Constructs a new ObjectArraytDataProvider wrapping the specified array and value of the includeFields property. |
|
| 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
|
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 |
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 The following methods will only be called if this method returns
|
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 |
java.lang.Object[] |
getArray()
Return the array that we are wrapping. |
FieldKey |
getFieldKey(java.lang.String fieldId)
Returns the |
FieldKey[] |
getFieldKeys()
|
java.lang.Class |
getObjectType()
Return the object type that this data provider contains. |
int |
getRowCount()
|
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)
Inserts a new row at the specified row. NOTE: The method should only be called after testing the
|
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 |
void |
removeRow(RowKey row)
Remove the object at the specified row from the list. |
void |
setArray(java.lang.Object[] array)
Replace the array that we are wrapping. |
void |
setIncludeFields(boolean includeFields)
Set the includeFields property. |
void |
setObjectType(java.lang.Class objectType)
Set the object type contained in this ObjectListDataProvider. |
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, isRowAvailable, 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 ObjectArrayDataProvider()
Construct a new ObjectArrayDataProvider with no known data. The
setArray() method can be used to set the contained array.
public ObjectArrayDataProvider(java.lang.Object[] array)
Constructs a new ObjectArraytDataProvider wrapping the specified array.
array - Array to be wrapped
public ObjectArrayDataProvider(java.lang.Object[] array,
boolean includeFields)
Constructs a new ObjectArraytDataProvider wrapping the specified
array and value of the includeFields property.
array - Array to be wrappedincludeFields - Desired includeFields property| Method Detail |
|---|
public java.lang.Object[] getArray()
Return the array that we are wrapping.
public void setArray(java.lang.Object[] array)
Replace the array that we are wrapping. In addition,
the objectType property will be reset based on the
class of the underlying element type.
array - The new array 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 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 value
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 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
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
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 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 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
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 TableDataProviderinsertRow in class AbstractTableDataProviderbeforeRow - 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
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)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||