public interface DataReader
DataReader
provides APIs for reading a structured data in streaming.
A structured data is a value that can be:
Here are some examples of usage. The data expected to be read is displayed in the JSON format.
Data:
trueCode:
dr.readBooleanValue(); // true
Data:
[ true, "MicroEJ", 2016 ]Code:
dr.readArrayValueStart(); dr.readBooleanValue(); // true dr.readStringValue(); // "MicroEJ" dr.readIntValue(); // 2016 dr.readArrayValueEnd();
Data:
{ "aKey1" : "MicroEJ", "aKey2" : 2016 }Code:
dr.readMapValueStart(); dr.readKeyString(); // "aKey1" dr.readStringValue(); // "MicroEJ" dr.readKeyString(); // "aKey2" dr.readIntValue(); // 2016 dr.readMapValueEnd();
Modifier and Type | Method and Description |
---|---|
boolean |
hasMoreElements()
Tells whether the current collection has more elements.
|
void |
readArrayValueEnd()
Reads the end of an array value.
|
void |
readArrayValueStart()
Reads the beginning of an array value.
|
boolean |
readBooleanValue()
Reads the next expected boolean value.
|
double |
readDoubleValue()
Reads the next expected double precision floating point value (64bits).
|
int |
readIntKey()
Reads the next expected integer key (signed 32bits) within the current map.
|
int |
readIntValue()
Reads the next expected integer value (signed 32bits).
|
long |
readLongValue()
Reads the next expected long integer value (signed 64bits).
|
void |
readMapValueEnd()
Reads the end of a map value.
|
void |
readMapValueStart()
Reads the beginning of a map value.
|
String |
readStringKey()
Reads the next expected
String key within the current map. |
String |
readStringValue()
Reads the next expected
String value. |
void |
skipValue()
Skip the next value.
|
boolean hasMoreElements() throws IOException
IOException
- on I/O error.void readArrayValueEnd() throws IOException
IOException
- on I/O error.IllegalStateException
- if the current collection is not an array.void readArrayValueStart() throws IOException
IOException
- on I/O error.IllegalStateException
- if the end of the data is reached or if a map key is expected.boolean readBooleanValue() throws IOException
IOException
- on I/O error.IllegalStateException
- if the end of the data is reached or if a map key is expected.double readDoubleValue() throws IOException
IOException
- on I/O error.IllegalStateException
- if the end of the data is reached or if a map key is expected.int readIntKey() throws IOException
IOException
- on I/O error.IllegalStateException
- if the current collection is not a map or if a map value is expected.int readIntValue() throws IOException
IOException
- on I/O error.IllegalStateException
- if the end of the data is reached or if a map key is expected.long readLongValue() throws IOException
IOException
- on I/O error.IllegalStateException
- if the end of the data is reached or if a map key is expected.void readMapValueEnd() throws IOException
IOException
- on I/O error.IllegalStateException
- if the current collection is not a map of if a key has been previously written without a value.void readMapValueStart() throws IOException
IOException
- on I/O error.IllegalStateException
- if the end of the data is reached or if a map key is expected.String readStringKey() throws IOException
String
key within the current map.IOException
- on I/O error.IllegalStateException
- if the current collection is not a map or if a map value is expected.String readStringValue() throws IOException
String
value.IOException
- on I/O error.IllegalStateException
- if the end of the data is reached or if a map key is expected.void skipValue() throws IOException
IOException
- on I/O error.IllegalStateException
- if the end of the data is reached or if a map key is expected.