-
- All Known Implementing Classes:
OctetDataReader
public interface DataReaderInput interface for reading binary messages into data objects.A message constructed by a
DataWritermay only contain object at top-level. Therefore the first call to an instance ofDataReadermust bebeginObject().- See Also:
DataWriter
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description intbeginArray()Starts reading an array.voidbeginObject()Starts reading an object.voidendArray()Finishes reading the array started withbeginArray().voidendObject()Finishes reading the object started with the last call tobeginObject().booleanhasNext()byte[]nextBinary()Reads a binary string value.InputStreamnextBinaryStream()Reads a binary stream value.default booleannextBoolean()Reads a boolean value.doublenextDouble()Reads a 64 bit double value.floatnextFloat()Reads a 32 bit float value.intnextInt()Reads an (unsigned) integer value.intnextIntFixed()Reads a full 32 bit integer value.intnextIntSigned()Reads a signed integer value.longnextLong()Reads an (unsigned) long value.longnextLongFixed()Reads a full 64 bit long value.longnextLongSigned()Reads a signed long value.intnextName()Whenreading an object, retrieves the next field identifier.StringnextString()Reads an utf-8Stringvalue.voidskipValue()Skips the current value to read.
-
-
-
Method Detail
-
beginObject
void beginObject() throws IOExceptionStarts reading an object.After this call, an alternating sequence of calls to
nextName()followed by a value retrieval method such asnextInt(),...nextString()followed by a final call toendObject()is expected.- Throws:
IOException- If reading fails.
-
endObject
void endObject() throws IOExceptionFinishes reading the object started with the last call tobeginObject().- Throws:
IOException- If reading fails.
-
hasNext
boolean hasNext() throws IOException- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextName
int nextName() throws IOExceptionWhenreading an object, retrieves the next field identifier.Note:
hasNext()must returntrueto be able to read the next field identifier.- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextBoolean
default boolean nextBoolean() throws IOExceptionReads a boolean value.- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextInt
int nextInt() throws IOExceptionReads an (unsigned) integer value.- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextIntSigned
int nextIntSigned() throws IOExceptionReads a signed integer value.- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextIntFixed
int nextIntFixed() throws IOExceptionReads a full 32 bit integer value.- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextLong
long nextLong() throws IOExceptionReads an (unsigned) long value.- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextLongSigned
long nextLongSigned() throws IOExceptionReads a signed long value.- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextLongFixed
long nextLongFixed() throws IOExceptionReads a full 64 bit long value.- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextFloat
float nextFloat() throws IOExceptionReads a 32 bit float value.- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextDouble
double nextDouble() throws IOExceptionReads a 64 bit double value.- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextString
String nextString() throws IOException
Reads an utf-8Stringvalue.- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextBinary
byte[] nextBinary() throws IOExceptionReads a binary string value.The value might have been produced by
DataWriter.value(byte[]), orDataWriter.valueBinaryStream(). Best efficiency is achieved, if a value produced withDataWriter.valueBinaryStream()is read bynextBinaryStream().- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextBinaryStream
InputStream nextBinaryStream() throws IOException
Reads a binary stream value.The value might have been produced by
DataWriter.value(byte[]), orDataWriter.valueBinaryStream(). Best efficiency is achieved, if a value produced withDataWriter.valueBinaryStream()is read bynextBinaryStream().- Returns:
- The retrieved value as stream.
- Throws:
IOException- If reading fails.
-
beginArray
int beginArray() throws IOExceptionStarts reading an array.- Returns:
- The number of array elements to read.
- Throws:
IOException- If reading fails.
-
endArray
void endArray() throws IOExceptionFinishes reading the array started withbeginArray().- Throws:
IOException- If reading fails.
-
skipValue
void skipValue() throws IOExceptionSkips the current value to read.- Throws:
IOException- If reading fails.
-
-