Module com.gluonhq.connect
Package com.gluonhq.connect.provider
Class InputStreamObjectDataReader<T>
- java.lang.Object
-
- com.gluonhq.connect.provider.InputStreamObjectDataReader<T>
-
- Type Parameters:
T
- the type of the object to read
- All Implemented Interfaces:
ObjectDataReader<T>
public class InputStreamObjectDataReader<T> extends Object implements ObjectDataReader<T>
A helper class that represents anObjectDataReader
that reads an object by reading from a specificInputDataSource
and converting the read data with a specificInputStreamInputConverter
.
-
-
Constructor Summary
Constructors Constructor Description InputStreamObjectDataReader(InputDataSource dataSource, InputStreamInputConverter<T> converter)
Construct an instance that will use the specified data source to read data from and convert it to an object with the specified converter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GluonObservableObject<T>
newGluonObservableObject()
Provide an instance of a GluonObservableObject.T
readObject()
Reads the object from the specified data source.
-
-
-
Constructor Detail
-
InputStreamObjectDataReader
public InputStreamObjectDataReader(InputDataSource dataSource, InputStreamInputConverter<T> converter)
Construct an instance that will use the specified data source to read data from and convert it to an object with the specified converter. The InputStream of the InputDataSource will be set on the Converter before calling itsread
method.- Parameters:
dataSource
- the data source where the data will be read fromconverter
- the converter that is used for converting the data into an object
-
-
Method Detail
-
newGluonObservableObject
public GluonObservableObject<T> newGluonObservableObject()
Description copied from interface:ObjectDataReader
Provide an instance of a GluonObservableObject. This method is called byDataProvider.retrieveObject(ObjectDataReader)
to get a GluonObservableObject that will contain the actual object when the retrieve operation has completed successfully. Most implementations will just return an instance of GluonObservableObject itself. Note that it is perfectly valid to return existing instances of GluonObservableObject.- Specified by:
newGluonObservableObject
in interfaceObjectDataReader<T>
- Returns:
- an instance of a GluonObservableObject
-
readObject
public T readObject() throws IOException
Reads the object from the specified data source. This implementation uses the specified converter to convert the data that is read from the specified data source into an object. The InputStream of the specified data source will be set on the converter, before calling theread
method on the converter.- Specified by:
readObject
in interfaceObjectDataReader<T>
- Returns:
- the read object
- Throws:
IOException
- when an exception occurred during the read process
-
-