public interface DataSource
A DataSource
may not always be available for serialization
purposes, so isClosed()
should be checked to avoid exceptions.
Modifier and Type | Method and Description |
---|---|
Optional<DataContainer> |
deserialize()
Deserializes all data existing in this source into a single
DataContainer . |
<T extends DataSerializable> |
deserialize(Class<T> clazz)
Deserializes the given class type from this source.
|
boolean |
isClosed()
Checks whether this source is still available for serialization operations.
|
void |
serialize(DataSerializable section)
Serializes the given
DataSerializable to this source. |
<T extends DataSerializable> Optional<T> deserialize(Class<T> clazz) throws InvalidDataException
A DataSource may have restrictions on the type of data it can handle. Inferring that a source can handle a particular kind of data is not safe.
T
- The type of object to produceclazz
- The class to deserialize toInvalidDataException
- If the data is incompatible with this sourceOptional<DataContainer> deserialize()
DataContainer
. This can be used for passing around data
containers without knowing the contents.void serialize(DataSerializable section) throws InvalidDataException
DataSerializable
to this source.
A DataSource may have restrictions on the type of data it can handle. Inferring that a source can handle a particular kind of data is not safe.
section
- The data object to serializeInvalidDataException
- If the data object is incompatible with this sourceboolean isClosed()