- java.lang.Object
-
- de.haumacher.msgbuf.binary.OctetDataReader
-
- All Implemented Interfaces:
DataReader
public class OctetDataReader extends Object implements DataReader
DataReaderthat reconstructs values written with aOctetDataWriter.
-
-
Constructor Summary
Constructors Constructor Description OctetDataReader(InputStream in)Creates aOctetDataReader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intbeginArray()Starts reading an array.voidbeginObject()Starts reading an object.voidendArray()Finishes reading the array started withDataReader.beginArray().voidendObject()Finishes reading the object started with the last call toDataReader.beginObject().booleanhasNext()byte[]nextBinary()Reads a binary string value.InputStreamnextBinaryStream()Reads a binary stream 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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.haumacher.msgbuf.binary.DataReader
nextBoolean
-
-
-
-
Constructor Detail
-
OctetDataReader
public OctetDataReader(InputStream in)
Creates aOctetDataReader.
-
-
Method Detail
-
beginObject
public void beginObject() throws IOExceptionDescription copied from interface:DataReaderStarts reading an object.After this call, an alternating sequence of calls to
DataReader.nextName()followed by a value retrieval method such asDataReader.nextInt(),...DataReader.nextString()followed by a final call toDataReader.endObject()is expected.- Specified by:
beginObjectin interfaceDataReader- Throws:
IOException- If reading fails.
-
endObject
public void endObject() throws IOExceptionDescription copied from interface:DataReaderFinishes reading the object started with the last call toDataReader.beginObject().- Specified by:
endObjectin interfaceDataReader- Throws:
IOException- If reading fails.
-
hasNext
public boolean hasNext() throws IOExceptionDescription copied from interface:DataReader- Specified by:
hasNextin interfaceDataReader- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextName
public int nextName() throws IOExceptionDescription copied from interface:DataReaderWhenreading an object, retrieves the next field identifier.Note:
DataReader.hasNext()must returntrueto be able to read the next field identifier.- Specified by:
nextNamein interfaceDataReader- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextInt
public int nextInt() throws IOExceptionDescription copied from interface:DataReaderReads an (unsigned) integer value.- Specified by:
nextIntin interfaceDataReader- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextIntSigned
public int nextIntSigned() throws IOExceptionDescription copied from interface:DataReaderReads a signed integer value.- Specified by:
nextIntSignedin interfaceDataReader- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextIntFixed
public int nextIntFixed() throws IOExceptionDescription copied from interface:DataReaderReads a full 32 bit integer value.- Specified by:
nextIntFixedin interfaceDataReader- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextLong
public long nextLong() throws IOExceptionDescription copied from interface:DataReaderReads an (unsigned) long value.- Specified by:
nextLongin interfaceDataReader- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextLongSigned
public long nextLongSigned() throws IOExceptionDescription copied from interface:DataReaderReads a signed long value.- Specified by:
nextLongSignedin interfaceDataReader- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextLongFixed
public long nextLongFixed() throws IOExceptionDescription copied from interface:DataReaderReads a full 64 bit long value.- Specified by:
nextLongFixedin interfaceDataReader- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextFloat
public float nextFloat() throws IOExceptionDescription copied from interface:DataReaderReads a 32 bit float value.- Specified by:
nextFloatin interfaceDataReader- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextDouble
public double nextDouble() throws IOExceptionDescription copied from interface:DataReaderReads a 64 bit double value.- Specified by:
nextDoublein interfaceDataReader- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextString
public String nextString() throws IOException
Description copied from interface:DataReaderReads an utf-8Stringvalue.- Specified by:
nextStringin interfaceDataReader- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextBinary
public byte[] nextBinary() throws IOExceptionDescription copied from interface:DataReaderReads 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 byDataReader.nextBinaryStream().- Specified by:
nextBinaryin interfaceDataReader- Returns:
- The retrieved value.
- Throws:
IOException- If reading fails.
-
nextBinaryStream
public InputStream nextBinaryStream() throws IOException
Description copied from interface:DataReaderReads 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 byDataReader.nextBinaryStream().- Specified by:
nextBinaryStreamin interfaceDataReader- Returns:
- The retrieved value as stream.
- Throws:
IOException- If reading fails.
-
beginArray
public int beginArray() throws IOExceptionDescription copied from interface:DataReaderStarts reading an array.- Specified by:
beginArrayin interfaceDataReader- Returns:
- The number of array elements to read.
- Throws:
IOException- If reading fails.
-
endArray
public void endArray() throws IOExceptionDescription copied from interface:DataReaderFinishes reading the array started withDataReader.beginArray().- Specified by:
endArrayin interfaceDataReader- Throws:
IOException- If reading fails.
-
skipValue
public void skipValue() throws IOExceptionDescription copied from interface:DataReaderSkips the current value to read.- Specified by:
skipValuein interfaceDataReader- Throws:
IOException- If reading fails.
-
-