public class DelegatedAsyncDataController extends Object implements AsyncDataController
AsyncDataController implementation which delegates all of its
methods to another AsyncDataController specified at construction
time.
This implementation does not declare any methods other than the ones
AsyncDataController offers but implements all of them by forwarding
to another AsyncDataController implementation specified at
construction time.
This class was designed for two reasons:
DelegatedAsyncDataController: specify the
AsyncDataController you want to "subclass" in the constructor and
override the required methods or provide new ones.
AsyncDataController from external
code. This way, the external code can only access methods which the
AsyncDataController interface provides.
AsyncDataController instance.
AsyncDataController instance.| Modifier and Type | Field and Description |
|---|---|
protected AsyncDataController |
wrappedController
The
AsyncDataController to which the methods are forwarded. |
| Constructor and Description |
|---|
DelegatedAsyncDataController(AsyncDataController controller)
Initializes the
wrappedController field with
the specified argument. |
| Modifier and Type | Method and Description |
|---|---|
void |
controlData(Object controlArg)
Notifies the
AsyncDataLink providing the data, that the data
should be provided in a specific way. |
AsyncDataState |
getDataState()
Returns the current progress of the data providing process.
|
String |
toString() |
protected final AsyncDataController wrappedController
AsyncDataController to which the methods are forwarded.
This field can never be null because the constructor throws
NullPointerException if null was specified as the
AsyncDataController.public DelegatedAsyncDataController(AsyncDataController controller)
wrappedController field with
the specified argument.controller - the AsyncDataController to which the methods
are forwarded. This argument cannot be null.NullPointerException - thrown if the specified
AsyncDataController is nullpublic void controlData(Object controlArg)
AsyncDataLink providing the data, that the data
should be provided in a specific way. This may affect the intermediate
incomplete datas only and regardless how and when this method was called
it may not affect the final and complete data provided by the
AsyncDataLink.
How exactly the data providing can be affected is entirely implementation dependent. For example an implementation may allow requests like "I don't need intermediate data, only the final one" or set up some priorities, that some part of the data should be provided as soon as possible and others are less important. Also implementations may choose to completely ignore this method call.
In general the order of the control arguments of multiple
controlData method call is considered to be important.
Note however, that this method only hints the AsyncDataLink and
usually implementations cannot make any hard guarantees that they will
honor the request.
controlData in interface AsyncDataControllercontrolArg - the control arguments defining the way how the data
should be provided. Implementations may make various restrictions on
what this argument is allowed to be (e.g.: its class). Note that the
control argument in general is expected to be safely sharable across
multiple threads concurrently and to be a relatively lightweight
object. That is, it is highly recommended that control arguments be
simple immutable objects only containing a minimal number of hints.public AsyncDataState getDataState()
This method must be implemented to return as quickly as possible. That
is, this method should do little more than accessing a volatile
field or similar actions.
In case actual providing of the data has not yet been started and the
implementation knows little or nothing about what kind of data will be
provided, it should return a null AsyncDataState rather
than a state with an arbitrary chosen class.
getDataState in interface AsyncDataControllernull if the state is not yet available.