Package com.yahoo.processing.response
Class ArrayDataList<DATATYPE extends Data>
java.lang.Object
com.yahoo.component.provider.FreezableClass
com.yahoo.component.provider.ListenableFreezableClass
com.yahoo.processing.response.AbstractDataList<DATATYPE>
com.yahoo.processing.response.ArrayDataList<DATATYPE>
- All Implemented Interfaces:
com.yahoo.component.provider.Freezable
,com.yahoo.component.provider.ListenableFreezable
,Data
,DataList<DATATYPE>
,Ordered
,Streamed
A data list backed by an array.
This implementation supports subclassing.
- Author:
- bratseth
-
Nested Class Summary
Nested classes/interfaces inherited from class com.yahoo.processing.response.AbstractDataList
AbstractDataList.DrainOnGetFuture<DATATYPE extends Data>
-
Constructor Summary
ModifierConstructorDescriptionprotected
ArrayDataList
(Request request) Creates a simple data list which does not allow late incoming dataprotected
ArrayDataList
(Request request, IncomingData<DATATYPE> incomingData) Creates a simple data list which receives incoming data in the given instanceprotected
ArrayDataList
(Request request, IncomingData<DATATYPE> incomingData, boolean ordered, boolean streamed) Creates a simple data list which receives incoming data in the given instance -
Method Summary
Modifier and TypeMethodDescriptionAdds a child data item to this.void
addDataListener
(Runnable runnable) Adds a listener which is invoked every time data is added to this list.asList()
Returns a reference to the list backing this.static <DATATYPE extends Data>
ArrayDataList<DATATYPE>Creates a simple data list which does not allow late incoming datastatic <DATATYPE extends Data>
ArrayDataList<DATATYPE>createAsync
(Request request) Creates an instance of this which supports incoming data through the default mechanism (DefaultIncomingData)static <DATATYPE extends Data>
ArrayDataList<DATATYPE>createAsyncNonstreamed
(Request request) Creates an instance of this which supports incoming data through the default mechanism (DefaultIncomingData) and where this data cannot be returned to clients until this is completed.static <DATATYPE extends Data>
ArrayDataList<DATATYPE>createAsyncUnordered
(Request request) Creates an instance of this which supports incoming data through the default mechanism (DefaultIncomingData), and where this data can be rendered in any order.void
freeze()
Irreversibly prevent further changes to the items of this.get
(int index) Returns the data element at indexMethods inherited from class com.yahoo.processing.response.AbstractDataList
completeFuture, incoming, isOrdered, isStreamed, request, toString
Methods inherited from class com.yahoo.component.provider.ListenableFreezableClass
addFreezeListener, clone
Methods inherited from class com.yahoo.component.provider.FreezableClass
ensureNotFrozen, isFrozen
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.yahoo.component.provider.Freezable
isFrozen
Methods inherited from interface com.yahoo.component.provider.ListenableFreezable
addFreezeListener
-
Constructor Details
-
ArrayDataList
Creates a simple data list which does not allow late incoming data- Parameters:
request
- the request which created this data list
-
ArrayDataList
Creates a simple data list which receives incoming data in the given instance- Parameters:
request
- the request which created this data list, never nullincomingData
- the recipient of incoming data to this list, never null
-
ArrayDataList
protected ArrayDataList(Request request, IncomingData<DATATYPE> incomingData, boolean ordered, boolean streamed) Creates a simple data list which receives incoming data in the given instance- Parameters:
request
- the request which created this data list, never nullincomingData
- the recipient of incoming data to this list, never null
-
-
Method Details
-
create
Creates a simple data list which does not allow late incoming data- Parameters:
request
- the request which created this data list
-
createAsync
Creates an instance of this which supports incoming data through the default mechanism (DefaultIncomingData) -
createAsyncUnordered
Creates an instance of this which supports incoming data through the default mechanism (DefaultIncomingData), and where this data can be rendered in any order. -
createAsyncNonstreamed
public static <DATATYPE extends Data> ArrayDataList<DATATYPE> createAsyncNonstreamed(Request request) Creates an instance of this which supports incoming data through the default mechanism (DefaultIncomingData) and where this data cannot be returned to clients until this is completed. -
add
Description copied from interface:DataList
Adds a child data item to this.- Parameters:
data
- the data to add to this- Returns:
- the input data instance, for chaining
-
get
Returns the data element at index -
asList
Returns a reference to the list backing this. The list may be modified freely, unless this is frozen. If frozen, the only permissible write operations are those that add new items to the end of the list. -
addDataListener
Description copied from interface:DataList
Adds a listener which is invoked every time data is added to this list. The listener is always invoked on the same thread which is adding the data, and hence it can modify this list freely without synchronization. -
freeze
public void freeze()Irreversibly prevent further changes to the items of this. This allows the processing engine to start streaming the current content of this list back to the client (if applicable).Adding new items to the end of this list is permitted even after freeze. If frozen, those items may be streamed back to the client immediately on add.
Calling this on a frozen list has no effect.
- Specified by:
freeze
in interfacecom.yahoo.component.provider.Freezable
- Overrides:
freeze
in classcom.yahoo.component.provider.ListenableFreezableClass
-