public interface DataWriter
DataWriter
provides APIs for writing a structured data in streaming.
The structured data format is documented in DataReader
.
Here are some examples of usage. The data expected to be written is displayed in the JSON format.
Data:
trueCode:
dw.writeBooleanValue(true);
Data:
[ true, "MicroEJ", 2016 ]Code:
dw.writeArrayValueStart(); dw.writeBooleanValue(true); dw.writeStringValue("MicroEJ"); dw.writeIntValue(2016); dw.writeArrayValueEnd();
Data:
{ "aKey1" : "MicroEJ", "aKey2" : 2016 }Code:
dw.writeMapValueStart(); dw.writeKeyString("aKey1"); dw.writeStringValue("MicroEJ"); dw.writeKeyString("aKey2"); dw.writeIntValue(2016); dw.writeMapValueEnd();
DataReader
Modifier and Type | Method and Description |
---|---|
void |
writeArrayValueEnd()
Writes the end of an array value.
|
void |
writeArrayValueStart()
Writes the beginning of an array value.
|
void |
writeBooleanValue(boolean value)
Writes the next boolean value.
|
void |
writeDoubleValue(double value)
Writes the next double precision floating point value (64bits).
|
void |
writeIntKey(int key)
Writes the expected integer key (signed 32bits) within the current map.
|
void |
writeIntValue(int value)
Writes the next integer value (signed 32bits).
|
void |
writeLongValue(long value)
Writes the next expected long integer value (signed 64bits).
|
void |
writeMapValueEnd()
Writes the end of a map value.
|
void |
writeMapValueStart()
Writes the beginning of a map value.
|
void |
writeStringKey(java.lang.String key)
Writes the expected
String key within the current map. |
void |
writeStringValue(java.lang.String value)
Writes the next
String value. |
void writeBooleanValue(boolean value) throws java.io.IOException
value
- the boolean value.java.io.IOException
- on I/O error.java.lang.IllegalStateException
- if the end of the data is reached or if a map key is expected.void writeIntValue(int value) throws java.io.IOException
value
- the int value.java.io.IOException
- on I/O error.java.lang.IllegalStateException
- if the end of the data is reached or if a map key is expected.void writeLongValue(long value) throws java.io.IOException
value
- the long value.java.io.IOException
- on I/O error.java.lang.IllegalStateException
- if the end of the data is reached or if a map key is expected.void writeDoubleValue(double value) throws java.io.IOException
value
- the double value.java.io.IOException
- on I/O error.java.lang.IllegalStateException
- if the end of the data is reached or if a map key is expected.void writeStringValue(java.lang.String value) throws java.io.IOException
String
value.value
- the String value.java.io.IOException
- on I/O error.java.lang.IllegalStateException
- if the end of the data is reached or if a map key is expected.void writeIntKey(int key) throws java.io.IOException
key
- the int key.java.io.IOException
- on I/O error.java.lang.IllegalStateException
- if the current collection is not a map or if a map value is expected.void writeStringKey(java.lang.String key) throws java.io.IOException
String
key within the current map.key
- the String key.java.io.IOException
- on I/O error.java.lang.IllegalStateException
- if the current collection is not a map or if a map value is expected.void writeArrayValueStart() throws java.io.IOException
java.io.IOException
- on I/O error.java.lang.IllegalStateException
- if the end of the data is reached or if a map key is expected.void writeArrayValueEnd() throws java.io.IOException
java.io.IOException
- on I/O error.java.lang.IllegalStateException
- if the current collection is not an array.void writeMapValueStart() throws java.io.IOException
java.io.IOException
- on I/O error.java.lang.IllegalStateException
- if the end of the data is reached or if a map key is expected.void writeMapValueEnd() throws java.io.IOException
java.io.IOException
- on I/O error.java.lang.IllegalStateException
- if the current collection is not a map of if a key has been previously written without a value.