public class ProgressiveSerializationImpl extends Object implements ProgressiveSerialization
ProgressiveSerialization
over FileOutputStream
.
This class is responsible to create a Deserializer
conform binary file over ProgressiveSerialization
interface.Modifier and Type | Class and Description |
---|---|
static class |
ProgressiveSerializationImpl.DeserializerImpl<T>
Deserializer.
|
Constructor and Description |
---|
ProgressiveSerializationImpl(File file,
int buffer,
boolean collectStats) |
Modifier and Type | Method and Description |
---|---|
<T extends Serializable> |
addDeferredAttribute(String name,
Class<T> type,
T initialValue)
Specify a named attribute.
|
void |
close()
Close the underlying resource and write retained index data.
|
ObjectOutputStream |
getObjectOutputStream()
Get output to write remainder data.
|
long |
getWrittenBytes() |
<T> void |
setDeserializer(Class<T> deserializedType,
ProgressiveDeserializer<T> progressiveDeserializer)
Specify deserializer to reconstruct the storage.
|
public ProgressiveSerializationImpl(File file, int buffer, boolean collectStats) throws IOException
IOException
public long getWrittenBytes()
public void close() throws IOException
ProgressiveSerialization
close
in interface ProgressiveSerialization
close
in interface AutoCloseable
IOException
public <T> void setDeserializer(Class<T> deserializedType, ProgressiveDeserializer<T> progressiveDeserializer)
ProgressiveSerialization
ObjectOutputStream
with a Deserializer
instance which
delegates to the passed progressiveDeserializer
.
Must be invoked before accessing #getDataOutput()
.setDeserializer
in interface ProgressiveSerialization
T
- Reconstructed storage typedeserializedType
- Reconstructed storage typeprogressiveDeserializer
- Deserializer to reconstruct the objectpublic <T extends Serializable> Consumer<T> addDeferredAttribute(String name, Class<T> type, T initialValue)
ProgressiveSerialization
RandomAccessFile
will write a placeholder which will be updated
later.addDeferredAttribute
in interface ProgressiveSerialization
T
- Typename
- Unique name of the attributetype
- TypeinitialValue
- Initial value to be stored. Any subsequent updates of the value must have exactly the
same serialized size.Consumer
to update value during the serialization.public ObjectOutputStream getObjectOutputStream()
ProgressiveSerialization
getObjectOutputStream
in interface ProgressiveSerialization