|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.data.provider.impl.MethodResultDataProvider
A DataProvider implementation to wrap the singleton (non-array) 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 DataProvider.
Constructor Summary | |
MethodResultDataProvider()
Constructs a new MethodResultDataProvider with no dataClassInstance or dataMethod specified. |
|
MethodResultDataProvider(java.lang.Object dataClassInstance,
java.lang.reflect.Method dataMethod)
Constructs a new MethodResultDataProvider using the specified dataClassInstance and dataMethod. |
Method Summary | |
void |
addDataListener(DataListener listener)
Register a new |
void |
addRefreshableDataListener(RefreshableDataListener l)
Register a new |
protected void |
fireRefreshed()
Fires a refreshed event to each registered RefreshableDataListener |
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.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
|
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 |
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 |
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
|
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 MethodResultDataProvider()
public MethodResultDataProvider(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 java.lang.Object getResultObject() 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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |