- java.lang.Object
-
- com.gluonhq.connect.provider.InputStreamListDataReader<E>
-
- Type Parameters:
E
- the type of the objects contained in the list to read
- All Implemented Interfaces:
ListDataReader<E>
public class InputStreamListDataReader<E> extends Object implements ListDataReader<E>
A helper class that represents aListDataReader
that reads objects by reading from a specificInputDataSource
and converts the read data with a specificInputStreamIterableInputConverter
.
-
-
Constructor Summary
Constructors Constructor Description InputStreamListDataReader(InputDataSource dataSource, InputStreamIterableInputConverter<E> converter)
Construct an instance that will use the specified data source to read data from and convert it to a list of objects with the specified converter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Iterator<E>
iterator()
Returns an iterator that is able to iterate over the read objects from the list.GluonObservableList<E>
newGluonObservableList()
Provide an instance of a GluonObservableList.
-
-
-
Constructor Detail
-
InputStreamListDataReader
public InputStreamListDataReader(InputDataSource dataSource, InputStreamIterableInputConverter<E> converter)
Construct an instance that will use the specified data source to read data from and convert it to a list of objects with the specified converter. The InputStream of the InputDataSource will be set on the Converter before calling itsiterator
method.- Parameters:
dataSource
- the data source where the data will be read fromconverter
- the converter that is used for converting the data into a list of object
-
-
Method Detail
-
newGluonObservableList
public GluonObservableList<E> newGluonObservableList()
Description copied from interface:ListDataReader
Provide an instance of a GluonObservableList. This method will be called byDataProvider.retrieveList(ListDataReader)
to get a GluonObservableList that can be populated. Most implementations will just return an instance of GluonObservableList itself. Note that it is perfectly valid to return existing instances of GluonObservableList.- Specified by:
newGluonObservableList
in interfaceListDataReader<E>
- Returns:
- an instance of GluonObservableList
-
iterator
public Iterator<E> iterator() throws IOException
Returns an iterator that is able to iterate over the read objects from the list. This implementation uses the specified converter to convert the data that is read from the specified data source into a list of objects. The InputStream of the specified data source will be set on the converter, before calling theiterator
method on the converter.- Specified by:
iterator
in interfaceListDataReader<E>
- Returns:
- an iterator that is able to read over the objects from the list
- Throws:
IOException
- when something went wrong during the process of reading the objects
-
-