public abstract class AbstractDataWriter extends java.lang.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 java.io.Flushable |
flushable
Flushable flushed when the end of the data has been written. |
protected ej.data.DataStreamState |
state |
Constructor and Description |
---|
AbstractDataWriter() |
AbstractDataWriter(java.io.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(java.lang.String key)
Writes the expected
String key within the current map. |
protected abstract void |
writeStringKey0(java.lang.String value) |
void |
writeStringValue(java.lang.String value)
Writes the next
String value. |
protected abstract void |
writeStringValue0(java.lang.String value) |
protected final ej.data.DataStreamState state
protected final java.io.Flushable flushable
Flushable
flushed when the end of the data has been written. May be null.public AbstractDataWriter(java.io.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.public AbstractDataWriter()
public final void writeBooleanValue(boolean value) throws java.io.IOException
DataWriter
writeBooleanValue
in interface DataWriter
value
- the boolean value.java.io.IOException
- on I/O error.public final void writeIntValue(int value) throws java.io.IOException
DataWriter
writeIntValue
in interface DataWriter
value
- the int value.java.io.IOException
- on I/O error.public final void writeLongValue(long value) throws java.io.IOException
DataWriter
writeLongValue
in interface DataWriter
value
- the long value.java.io.IOException
- on I/O error.public final void writeDoubleValue(double value) throws java.io.IOException
DataWriter
writeDoubleValue
in interface DataWriter
value
- the double value.java.io.IOException
- on I/O error.public final void writeStringValue(java.lang.String value) throws java.io.IOException
DataWriter
String
value.writeStringValue
in interface DataWriter
value
- the String value.java.io.IOException
- on I/O error.public final void writeStringKey(java.lang.String key) throws java.io.IOException
DataWriter
String
key within the current map.writeStringKey
in interface DataWriter
key
- the String key.java.io.IOException
- on I/O error.public final void writeIntKey(int key) throws java.io.IOException
DataWriter
writeIntKey
in interface DataWriter
key
- the int key.java.io.IOException
- on I/O error.public final void writeArrayValueStart() throws java.io.IOException
DataWriter
writeArrayValueStart
in interface DataWriter
java.io.IOException
- on I/O error.public final void writeArrayValueEnd() throws java.io.IOException
DataWriter
writeArrayValueEnd
in interface DataWriter
java.io.IOException
- on I/O error.public final void writeMapValueStart() throws java.io.IOException
DataWriter
writeMapValueStart
in interface DataWriter
java.io.IOException
- on I/O error.public final void writeMapValueEnd() throws java.io.IOException
DataWriter
writeMapValueEnd
in interface DataWriter
java.io.IOException
- on I/O error.protected void end() throws java.io.IOException
Flushable.flush()
method of the Flushable
given
to the constructor.java.io.IOException
- on I/O error.protected abstract void writeBooleanValue0(boolean value) throws java.lang.Throwable
java.lang.Throwable
protected abstract void writeIntValue0(int value) throws java.lang.Throwable
java.lang.Throwable
protected abstract void writeLongValue0(long value) throws java.lang.Throwable
java.lang.Throwable
protected abstract void writeDoubleValue0(double value) throws java.lang.Throwable
java.lang.Throwable
protected abstract void writeStringValue0(java.lang.String value) throws java.lang.Throwable
java.lang.Throwable
protected abstract void writeIntKey0(int value) throws java.lang.Throwable
java.lang.Throwable
protected abstract void writeStringKey0(java.lang.String value) throws java.lang.Throwable
java.lang.Throwable
protected abstract void writeArrayValueStart0() throws java.lang.Throwable
java.lang.Throwable
protected abstract void writeArrayValueEnd0() throws java.lang.Throwable
java.lang.Throwable
protected abstract void writeMapValueStart0() throws java.lang.Throwable
java.lang.Throwable
protected abstract void writeMapValueEnd0() throws java.lang.Throwable
java.lang.Throwable