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
public class ArrayDataList<DATATYPE extends Data> extends AbstractDataList<DATATYPE>
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
Constructors Modifier Constructor Description protected
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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DATATYPE
add(DATATYPE data)
Adds a child data item to this.void
addDataListener(java.lang.Runnable runnable)
Adds a listener which is invoked every time data is added to this list.java.util.List<DATATYPE>
asList()
Returns a reference to the list backing this.static <DATATYPE extends Data>
ArrayDataList<DATATYPE>create(Request request)
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.DATATYPE
get(int index)
Returns the data element at index-
Methods inherited from class com.yahoo.processing.response.AbstractDataList
complete, incoming, isOrdered, isStreamed, request, toString
-
Methods inherited from class com.yahoo.component.provider.ListenableFreezableClass
addFreezeListener, clone
-
-
-
-
Constructor Detail
-
ArrayDataList
protected ArrayDataList(Request request)
Creates a simple data list which does not allow late incoming data- Parameters:
request
- the request which created this data list
-
ArrayDataList
protected ArrayDataList(Request request, IncomingData<DATATYPE> incomingData)
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 Detail
-
create
public static <DATATYPE extends Data> ArrayDataList<DATATYPE> create(Request request)
Creates a simple data list which does not allow late incoming data- Parameters:
request
- the request which created this data list
-
createAsync
public static <DATATYPE extends Data> ArrayDataList<DATATYPE> createAsync(Request request)
Creates an instance of this which supports incoming data through the default mechanism (DefaultIncomingData)
-
createAsyncUnordered
public 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.
-
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
public DATATYPE add(DATATYPE data)
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
public DATATYPE get(int index)
Returns the data element at index
-
asList
public java.util.List<DATATYPE> 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
public void addDataListener(java.lang.Runnable runnable)
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
-
-