|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.data.provider.impl.MethodResultTableDataProvider
A TableDataProvider implementation to wrap the return value from a method.
Set the dataClassInstance
, dataMethod
, and
dataMethodArguments
properties to point to a method on a class
instance. The result from that method call will be wrapped as a
TableDataProvider, with a row for each element in the returned array or
collection. If there is only a single return value, it will be a single row
table.
Constructor Summary | |
MethodResultTableDataProvider()
Constructs a new MethodResultTableDataProvider with no dataClassInstance or dataMethod specified. |
|
MethodResultTableDataProvider(java.lang.Object dataClassInstance,
java.lang.reflect.Method dataMethod)
Constructs a new MethodResultTableDataProvider using the specified dataClassInstance and dataMethod. |
Method Summary | |
void |
addDataListener(DataListener listener)
Register a new |
void |
addRefreshableDataListener(RefreshableDataListener l)
Register a new |
void |
addTableCursorListener(TableCursorListener l)
Register a new |
void |
addTableDataListener(TableDataListener l)
Register a new |
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 |
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. |
protected void |
fireRefreshed()
Fires a refreshed event to each registered RefreshableDataListener |
java.lang.Class |
getCollectionElementType()
|
RowKey |
getCursorRow()
|
java.lang.Object |
getDataClassInstance()
Returns the dataClassInstance that contains the dataMethod to be invoked. |
DataListener[] |
getDataListeners()
|
java.lang.reflect.Method |
getDataMethod()
Returns the currently set dataMethod |
java.lang.Object[] |
getDataMethodArguments()
Returns the dataMethodArguments |
FieldKey |
getFieldKey(java.lang.String fieldId)
Returns the |
FieldKey[] |
getFieldKeys()
|
RefreshableDataListener[] |
getRefreshableDataListeners()
|
java.lang.Object |
getResultObject()
Read-only access to the result object from the invokation of the dataMethod |
java.lang.Object[] |
getResultObjects()
Read-only access to the result object array from the invokation of the dataMethod |
int |
getRowCount()
|
RowKey |
getRowKey(java.lang.String rowId)
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. |
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. |
TableCursorListener[] |
getTableCursorListeners()
|
TableDataListener[] |
getTableDataListeners()
|
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 row)
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
|
void |
invokeDataMethod()
Invokes the dataMethod using the arguments specified by the dataMethodArguments property. |
void |
invokeDataMethod(java.lang.Object[] args)
Invokes the dataMethod using the specified arguments. |
boolean |
isIncludeFields()
|
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 |
void |
refresh()
Invokes the dataMethod on the dataClassInstance to refresh the data provider's contets |
protected void |
refreshFieldKeys()
Refreshes the list of available fieldKeys (based on the return type of the dataMethod) |
void |
removeDataListener(DataListener listener)
Deregister an existing |
void |
removeRefreshableDataListener(RefreshableDataListener l)
Deregister an existing |
void |
removeRow(RowKey row)
Removes the specified row. NOTE: The method should only be called after testing the
|
void |
removeTableCursorListener(TableCursorListener l)
Deregister an existing |
void |
removeTableDataListener(TableDataListener l)
Deregister an existing |
void |
setCollectionElementType(java.lang.Class elementType)
If the dataMethod returns a Collection type, this property
will be used to determine the appropriate FieldKeys for the elements in
the collection type. |
void |
setCursorRow(RowKey row)
Sets the cursor to the row represented by the passed |
void |
setDataClassInstance(java.lang.Object instance)
Sets the dataClassInstance that contains the dataMethod to be invoked. |
void |
setDataMethod(java.lang.reflect.Method method)
Sets the dataMethod that will be invoked |
void |
setDataMethodArguments(java.lang.Object[] methodArgs)
Sets the dataMethodArguments, which will be passed to the dataMethod when it is invoked. |
void |
setIncludeFields(boolean includeFields)
Sets the includeFields 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 row,
java.lang.Object value)
Sets the value of the data element represented by the specified
|
protected void |
testInvokeDataMethod()
Tests to see if the dataMethod has been invoked, and invokes it if it has not. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public MethodResultTableDataProvider()
public MethodResultTableDataProvider(java.lang.Object dataClassInstance, java.lang.reflect.Method dataMethod)
dataClassInstance
- The class instance where the method is invokeddataMethod
- The method where the data is fromMethod Detail |
public java.lang.Object getDataClassInstance()
public void setDataClassInstance(java.lang.Object instance)
instance
- Objectpublic java.lang.reflect.Method getDataMethod()
public void setDataMethod(java.lang.reflect.Method method)
method
- Methodpublic void setCollectionElementType(java.lang.Class elementType)
Collection
type, this property
will be used to determine the appropriate FieldKeys for the elements in
the collection type.
elementType
- Classpublic java.lang.Class getCollectionElementType()
public java.lang.Object getResultObject() throws DataProviderException
DataProviderException
public java.lang.Object[] getResultObjects() throws DataProviderException
DataProviderException
public void setIncludeFields(boolean includeFields)
Sets the includeFields property. This affects the set of FieldKey
s that this DataProvider
emits.
If includeFields is set to true (the default), then public fields will
be included in the list of available keys (intermixed with the public
properties). If it is set to false, then only the public properties
will be available.
includeFields
- true
to include the public fields, or
false
to exclude them (and only show public
properties)public boolean isIncludeFields()
protected void refreshFieldKeys()
public void setDataMethodArguments(java.lang.Object[] methodArgs)
methodArgs
- Object[]public java.lang.Object[] getDataMethodArguments()
public void invokeDataMethod() throws DataProviderException
DataProviderException
public void invokeDataMethod(java.lang.Object[] args) throws DataProviderException
args
- Object[]
DataProviderException
protected void testInvokeDataMethod() throws DataProviderException
DataProviderException
public void refresh() throws DataProviderException
refresh
in interface RefreshableDataProvider
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 addRefreshableDataListener(RefreshableDataListener l)
Register a new RefreshableDataListener
to this
RefreshableDataProvider
instance.
addRefreshableDataListener
in interface RefreshableDataProvider
l
- New RefreshableDataListener
to registerpublic void removeRefreshableDataListener(RefreshableDataListener l)
Deregister an existing RefreshableDataListener
from
RefreshableDataProvider
instance.
removeRefreshableDataListener
in interface RefreshableDataProvider
l
- Old RefreshableDataListener
to removepublic RefreshableDataListener[] getRefreshableDataListeners()
getRefreshableDataListeners
in interface RefreshableDataProvider
RefreshableDataListener
s
currently registered on this RefreshableDataProvider
.
If there are no registered listeners, a zero-length array is
returned.protected void fireRefreshed()
RefreshableDataListener
RefreshableDataListener.refreshed(RefreshableDataProvider)
public FieldKey[] getFieldKeys() throws DataProviderException
getFieldKeys
in interface DataProvider
FieldKey
s supported by this
DataProvider
. If the set of valid FieldKey
s 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 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
fieldId
- 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 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
fieldKey
- 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 DataProvider
fieldKey
- 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 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
fieldKey
- 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 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
fieldKey
- 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 addDataListener(DataListener listener)
Register a new DataListener
to this DataProvider
instance.
addDataListener
in interface DataProvider
listener
- New DataListener
to registerpublic void removeDataListener(DataListener listener)
Deregister an existing DataListener
from this
DataProvider instance.
removeDataListener
in interface DataProvider
listener
- Old DataListener
to deregisterpublic DataListener[] getDataListeners()
getDataListeners
in interface DataProvider
DataListener
s currently
registered on this DataProvider. If there are no registered
listeners, a zero-length array is returned.public int getRowCount() throws DataProviderException
getRowCount
in interface TableDataProvider
TableDataProvider
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 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 TableDataProvider
row
- 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 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 TableDataProvider
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.
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
getRowKey
in interface TableDataProvider
rowId
- 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 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 TableDataProvider
fieldKey
- 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 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 TableDataProvider
fieldKey
- 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 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 TableDataProvider
beforeRow
- 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 TableDataProvider
beforeRow
- 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 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 TableDataProvider
true
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 TableDataProvider
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.TableDataProvider.canAppendRow()
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 TableDataProvider
row
- 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
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
row
- 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 addTableDataListener(TableDataListener l)
Register a new TableDataListener
to this TableDataProvider
instance.
addTableDataListener
in interface TableDataProvider
l
- New TableDataListener
to registerpublic void removeTableDataListener(TableDataListener l)
Deregister an existing TableDataListener
from this
TableDataProvider instance.
removeTableDataListener
in interface TableDataProvider
l
- Old TableDataListener
to deregisterpublic TableDataListener[] getTableDataListeners()
getTableDataListeners
in interface TableDataProvider
TableDataListener
s currently registered
on this TableDataProvider. If there are no registered listeners,
a zero-length array is returned.public RowKey getCursorRow() throws DataProviderException
getCursorRow
in interface TableDataProvider
RowKey
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 TableDataProvider
row
- New RowKey
to move the cursor to.
TableCursorVetoException
- if a TableCursorListener decides to
veto the cursor navigationpublic boolean cursorFirst() throws DataProviderException
Move the cursor to the first row in this TableDataProvider.
cursorFirst
in interface TableDataProvider
true
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 TableDataProvider
true
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 TableDataProvider
true
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 TableDataProvider
true
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 void addTableCursorListener(TableCursorListener l)
Register a new TableCursorListener
to this TableDataProvider
instance.
addTableCursorListener
in interface TableDataProvider
l
- New TableCursorListener
to registerpublic void removeTableCursorListener(TableCursorListener l)
Deregister an existing TableCursorListener
from this
TableDataProvider instance.
removeTableCursorListener
in interface TableDataProvider
l
- Old TableCursorListener
to deregisterpublic TableCursorListener[] getTableCursorListeners()
getTableCursorListeners
in interface TableDataProvider
TableCursorListener
s currently registered
on this TableDataProvider. If there are no registered listeners,
a zero-length array is returned.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |