docs/javadoc/reference/com/facebook/datasource/AbstractDataSource.html
|
|
Summary: Nested Classes | Protected Ctors | Methods | Protected Methods | Inherited Methods | [Expand All]
public abstract class
extends Object
implements DataSource<T>
| java.lang.Object | | ↳ | com.facebook.datasource.AbstractDataSource<T> |
| Known Direct Subclasses
AbstractProducerToDataSourceAdapter<T>, ListDataSource<T>, SettableDataSource<T>, SimpleDataSource<T>
| AbstractProducerToDataSourceAdapter<T> | DataSource backed by a Producer |
| ListDataSource<T> | Data source that wraps number of other data sources and waits until all of them are finished. |
| SettableDataSource<T> | A DataSource whose result may be set by a #set(CloseableReference) or setException(Throwable) call. |
| SimpleDataSource<T> | Settable DataSource. |
|
| Known Indirect Subclasses
CloseableProducerToDataSourceAdapter<T>, ProducerToDataSourceAdapter<T>
| CloseableProducerToDataSourceAdapter<T> | DataSource> backed by a Producer> | | ProducerToDataSourceAdapter<T> | DataSource backed by a Producer |
|
An abstract implementation of DataSource interface.
It is highly recommended that other data sources extend this class as it takes care of the state, as well as of notifying listeners when the state changes.
Subclasses should override closeResult(T) if results need clean up
| Nested Classes |
|---|
| interface |
| Protected Constructors |
|---|
| Public Methods |
|---|
| boolean |
| Cancels the ongoing request and releases all associated resources. |
| static AbstractDataSource.DataSourceInstrumenter |
| Map<String, Object> |
| synchronized Throwable |
| synchronized float |
| synchronized T |
| The most recent result of the asynchronous computation. |
| synchronized boolean |
| boolean |
| synchronized boolean |
| synchronized boolean |
| synchronized boolean |
| static void |
| boolean |
| void |
| Subscribe for notifications whenever the state of the DataSource changes. |
| Protected Methods |
|---|
| void |
| Subclasses should override this method to close the result that is not needed anymore. |
| void |
| void |
| void |
| boolean |
| Subclasses should invoke this method to set the failure. |
| boolean |
| boolean |
| Subclasses should invoke this method to set the progress. |
| boolean |
Subclasses should invoke this method to set the result to value. |
| [Expand] Inherited Methods | | --- | | From class java.lang.Object
| Object | clone() | | boolean | equals(Object arg0) | | void | finalize() | | final Class<?> | getClass() | | int | hashCode() | | final void | notify() | | final void | notifyAll() | | String | toString() | | final void | wait(long arg0, int arg1) | | final void | wait(long arg0) | | final void | wait() |
| | From interface com.facebook.datasource.DataSource
| abstract boolean | close() Cancels the ongoing request and releases all associated resources. | | abstract Map<String, Object> | getExtras() | | abstract Throwable | getFailureCause() | | abstract float | getProgress() | | abstract T | getResult() The most recent result of the asynchronous computation. | | abstract boolean | hasFailed() | | abstract boolean | hasMultipleResults() | | abstract boolean | hasResult() | | abstract boolean | isClosed() | | abstract boolean | isFinished() | | abstract void | subscribe(DataSubscriber<T> dataSubscriber, Executor executor) Subscribe for notifications whenever the state of the DataSource changes. |
|
Cancels the ongoing request and releases all associated resources.
Subsequent calls to getResult() will return null.
The most recent result of the asynchronous computation.
The caller gains ownership of the object and is responsible for releasing it. Note that subsequent calls to getResult might give different results. Later results should be considered to be of higher quality.
This method will return null in the following cases:
hasResult returns false).Subscribe for notifications whenever the state of the DataSource changes.
All changes will be observed on the provided executor.
Subclasses should override this method to close the result that is not needed anymore.
This method is called in two cases: 1. to clear the result when data source gets closed 2. to clear the previous result when a new result is set
Subclasses should invoke this method to set the failure.
This method will return true if the failure was successfully set, or false if the data source has already been set, failed or closed.
If the failure was successfully set, state of the data source will be set to AbstractDataSource.DataSourceStatus#FAILURE.
This will also notify the subscribers if the failure was successfully set.
Do NOT call this method from a synchronized block as it invokes external code of the subscribers.
| throwable | the failure cause to be set. |
Subclasses should invoke this method to set the progress.
This method will return true if the progress was successfully set, or false if the data source has already been set, failed or closed.
This will also notify the subscribers if the progress was successfully set.
Do NOT call this method from a synchronized block as it invokes external code of the subscribers.
| progress | the progress in range [0, 1] to be set. |
Subclasses should invoke this method to set the result to value.
This method will return true if the value was successfully set, or false if the data source has already been set, failed or closed.
If the value was successfully set and isLast is true, state of the data source will be set to AbstractDataSource.DataSourceStatus#SUCCESS.
closeResult(T) will be called for the previous result if the new value was successfully set, OR for the new result otherwise.
This will also notify the subscribers if the value was successfully set.
Do NOT call this method from a synchronized block as it invokes external code of the subscribers.
| value | the value that was the result of the task. | | isLast | whether or not the value is last. | | extras | an object with extra data for this datasource |
+Generated by Doclava. +