public abstract class AbstractDataWriter extends Object implements DataWriter
DataWriter
interface with the following features:
DataWriter
interface (an IllegalStateException
thrown on error).0
(e.g writeBoolean
calls writeBoolean0
). Methods can throw any kind of exceptions that will be wrapped into an IOException
.end()
method is called when the data is terminated. This method calls the Flushable.flush()
of the Flushable
given to the constructor.Modifier and Type | Field and Description |
---|---|
protected Flushable |
flushable
Flushable flushed when the end of the data has been written. |
protected ej.data.DataStreamState |
state |
Constructor and Description |
---|
AbstractDataWriter() |
AbstractDataWriter(Flushable flushable)
Creates a new
AbstractDataWriter that will use the given Flushable to notify the end of the data. |
Modifier and Type | Method and Description |
---|---|
protected void |
end()
This method is called when the data has been fully written, giving
a "finalization" hook to the implementation.
|
void |
writeArrayValueEnd()
Writes the end of an array value.
|
protected abstract void |
writeArrayValueEnd0() |
void |
writeArrayValueStart()
Writes the beginning of an array value.
|
protected abstract void |
writeArrayValueStart0() |
void |
writeBooleanValue(boolean value)
Writes the next boolean value.
|
protected abstract void |
writeBooleanValue0(boolean value) |
void |
writeDoubleValue(double value)
Writes the next double precision floating point value (64bits).
|
protected abstract void |
writeDoubleValue0(double value) |
void |
writeIntKey(int key)
Writes the expected integer key (signed 32bits) within the current map.
|
protected abstract void |
writeIntKey0(int value) |
void |
writeIntValue(int value)
Writes the next integer value (signed 32bits).
|
protected abstract void |
writeIntValue0(int value) |
void |
writeLongValue(long value)
Writes the next expected long integer value (signed 64bits).
|
protected abstract void |
writeLongValue0(long value) |
void |
writeMapValueEnd()
Writes the end of a map value.
|
protected abstract void |
writeMapValueEnd0() |
void |
writeMapValueStart()
Writes the beginning of a map value.
|
protected abstract void |
writeMapValueStart0() |
void |
writeStringKey(String key)
Writes the expected
String key within the current map. |
protected abstract void |
writeStringKey0(String value) |
void |
writeStringValue(String value)
Writes the next
String value. |
protected abstract void |
writeStringValue0(String value) |
protected final Flushable flushable
Flushable
flushed when the end of the data has been written. May be null.protected final ej.data.DataStreamState state
public AbstractDataWriter()
public AbstractDataWriter(Flushable flushable)
AbstractDataWriter
that will use the given Flushable
to notify the end of the data.
The Flushable.flush()
method of the Flushable
is called when end of the data is reached.flushable
- the Flushable
used to flush. May be null.protected void end() throws IOException
Flushable.flush()
method of the Flushable
given
to the constructor.IOException
- on I/O error.public final void writeArrayValueEnd() throws IOException
DataWriter
writeArrayValueEnd
in interface DataWriter
IOException
- on I/O error.protected abstract void writeArrayValueEnd0() throws Throwable
Throwable
public final void writeArrayValueStart() throws IOException
DataWriter
writeArrayValueStart
in interface DataWriter
IOException
- on I/O error.protected abstract void writeArrayValueStart0() throws Throwable
Throwable
public final void writeBooleanValue(boolean value) throws IOException
DataWriter
writeBooleanValue
in interface DataWriter
value
- the boolean value.IOException
- on I/O error.protected abstract void writeBooleanValue0(boolean value) throws Throwable
Throwable
public final void writeDoubleValue(double value) throws IOException
DataWriter
writeDoubleValue
in interface DataWriter
value
- the double value.IOException
- on I/O error.protected abstract void writeDoubleValue0(double value) throws Throwable
Throwable
public final void writeIntKey(int key) throws IOException
DataWriter
writeIntKey
in interface DataWriter
key
- the int key.IOException
- on I/O error.public final void writeIntValue(int value) throws IOException
DataWriter
writeIntValue
in interface DataWriter
value
- the int value.IOException
- on I/O error.public final void writeLongValue(long value) throws IOException
DataWriter
writeLongValue
in interface DataWriter
value
- the long value.IOException
- on I/O error.protected abstract void writeLongValue0(long value) throws Throwable
Throwable
public final void writeMapValueEnd() throws IOException
DataWriter
writeMapValueEnd
in interface DataWriter
IOException
- on I/O error.public final void writeMapValueStart() throws IOException
DataWriter
writeMapValueStart
in interface DataWriter
IOException
- on I/O error.protected abstract void writeMapValueStart0() throws Throwable
Throwable
public final void writeStringKey(String key) throws IOException
DataWriter
String
key within the current map.writeStringKey
in interface DataWriter
key
- the String key.IOException
- on I/O error.protected abstract void writeStringKey0(String value) throws Throwable
Throwable
public final void writeStringValue(String value) throws IOException
DataWriter
String
value.writeStringValue
in interface DataWriter
value
- the String value.IOException
- on I/O error.