Class AsyncReport
Note that this class does not have a public constructor and can only be
initiated by the static factory method: getReport(Throwable, boolean).
The following two properties of the data transfer completion are supported:
- If it was canceled or not.
- The exception describing the error occurred while transferring the data.
AsyncDataLink instances report that the data transferring was
canceled, it should be interpreted as the final data
received might not be the fully complete (but can be) data intended to be
retrieved. Also when a non-null exception is attached
to the AsyncReport instance, the final data might not be the fully
complete data due to some errors while trying to retrieve the required data.
Thread safety
Instances of this class are completely safe to be accessed from multiple threads concurrently. Also, instances are immutable except that the attached exception (as every exception in Java) is mutable. Note however, that exceptions are safe to be accessed from multiple threads concurrently.Synchronization transparency
The methods of this class are synchronization transparent.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final AsyncReportA canceled but error free data transfer.static final AsyncReportA completely successful data transfer. -
Method Summary
Modifier and TypeMethodDescriptionReturns the exception describing the error occurred during the data transfer of which completion thisAsyncReportrepresents.static AsyncReportReturns anAsyncReportinstance with the specified exception attached to it and deriving the canceled state from the type of the exception.static AsyncReportReturns anAsyncReportinstance with the specified exception attached to it and with the specified canceled state.booleanReturnstrueif thisAsyncReportdefines a canceled data transfer.booleanReturnstrueif thisAsyncReportdefines a completely successful completion of a data transfer.toString()Returns the string representation of thisAsyncReportin no particular format.
-
Field Details
-
SUCCESS
A completely successful data transfer. ThisAsyncReportinstance is notcanceledand does not have an exception object attached to it.This
AsyncReportobject is completely immutable. -
CANCELED
A canceled but error free data transfer. ThisAsyncReportinstance iscanceledand does not have an exception object attached to it.This
AsyncReportobject is completely immutable.
-
-
Method Details
-
getReport
Returns anAsyncReportinstance with the specified exception attached to it and deriving the canceled state from the type of the exception. That is, if the exception is an instance ofOperationCanceledException, the operations is assumed to be canceled.Note that this method does not necessarily returns a new unique object if not necessary.
- Parameters:
exception- the exception attached to the returnedAsyncReportinstance. This is the exception which will be returned by thegetException()method of the createdAsyncReport. This argument can benullwhich means that no exception is attached to the returnedAsyncReportinstance, that is the data retrieval process has terminate without errors.- Returns:
- the
AsyncReportinstance with the specified exception attached to it and the derived canceled state. This method never returnsnull.
-
getReport
Returns anAsyncReportinstance with the specified exception attached to it and with the specified canceled state.Note that this method does not necessarily returns a new unique object if not necessary.
- Parameters:
exception- the exception attached to the returnedAsyncReportinstance. This is the exception which will be returned by thegetException()method of the createdAsyncReport. This argument can benullwhich means that no exception is attached to the returnedAsyncReportinstance, that is the data retrieval process has terminate without errors.canceled- the canceled state of the returnedAsyncReportinstance. This value will be returned by theisCanceledmethod of the returnedAsyncReportinstance.- Returns:
- the
AsyncReportinstance with the specified exception attached to it and with the specified canceled state. This method never returnsnull.
-
isSuccess
public boolean isSuccess()Returnstrueif thisAsyncReportdefines a completely successful completion of a data transfer. That is, if it was notcanceledand does not have an exception attached to it.If this method returns
true, a data transfer requested from anAsyncDataLinkmust have returned the complete requested data.- Returns:
trueif thisAsyncReportdefines a completely successful completion of a data transfer,falseotherwise- See Also:
-
isCanceled
public boolean isCanceled()Returnstrueif thisAsyncReportdefines a canceled data transfer.If this method returns
true, a data transfer requested from anAsyncDataLinkmay not have returned the complete requested data.- Returns:
trueif thisAsyncReportdefines a canceled data transfer,falseotherwise
-
getException
Returns the exception describing the error occurred during the data transfer of which completion thisAsyncReportrepresents.If this method returns a non-null exception, a data transfer requested from an
AsyncDataLinkmay not have returned the complete requested data.- Returns:
- the exception describing the error occurred during the data
transfer of which completion this
AsyncReportrepresents ornullif no error occurred while transferring the data
-
toString
Returns the string representation of thisAsyncReportin no particular format.This method is intended to be used for debugging only.
-