- java.lang.Object
-
- de.haumacher.msgbuf.binary.OctetDataWriter
-
- All Implemented Interfaces:
DataWriter
public class OctetDataWriter extends Object implements DataWriter
DataWriterthat encodes into a stream of octets (8 bit byte values).
-
-
Constructor Summary
Constructors Constructor Description OctetDataWriter(OutputStream out)Creates aOctetDataWriter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbeginArray(DataType type, int length)Starts writing an array value with entries of the given type.voidbeginObject()Starts writing an object.voidendArray()Stops writing the array started with the last call toDataWriter.beginObject().voidendObject()Finishes writing the fields of the object started with the last call toDataWriter.beginObject().voidname(int id)Writes an identifier of a field fo the currently written object.voidvalue(byte[] value)Writes a binary string value.voidvalue(double value)Writes adoublevalue.voidvalue(float value)Writes afloatvalue.voidvalue(int value)Writes an unsignedintvalue.voidvalue(long value)Writes an unsignedlongvalue.voidvalue(String value)Writes aStringvalue inutf-8encoding.OutputStreamvalueBinaryStream()Starts writing a binary value of arbitrary length in chunked mode.voidvalueFixed(int value)Writes a fixed size 32 bitintvalue.voidvalueFixed(long value)Writes a fixed size 64 bitlongvalue.voidvalueSigned(int value)Writes a signedintvalue.voidvalueSigned(long value)Writes a signedlongvalue.-
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.DataWriter
value
-
-
-
-
Constructor Detail
-
OctetDataWriter
public OctetDataWriter(OutputStream out)
Creates aOctetDataWriter.
-
-
Method Detail
-
beginObject
public void beginObject() throws IOExceptionDescription copied from interface:DataWriterStarts writing an object.A sequence of interleaving calls to
DataWriter.name(int)and a value encoding method such asDataWriter.value(int)is expected followed by a finalDataWriter.endObject()call.- Specified by:
beginObjectin interfaceDataWriter- Throws:
IOException- If writing fails.
-
endObject
public void endObject() throws IOExceptionDescription copied from interface:DataWriterFinishes writing the fields of the object started with the last call toDataWriter.beginObject().- Specified by:
endObjectin interfaceDataWriter- Throws:
IOException- If writing fails.
-
beginArray
public void beginArray(DataType type, int length) throws IOException
Description copied from interface:DataWriterStarts writing an array value with entries of the given type.- Specified by:
beginArrayin interfaceDataWriter- Parameters:
type- The type of the array elements.length- The number of elements that follow.- Throws:
IOException- If writing fails.
-
endArray
public void endArray() throws IOExceptionDescription copied from interface:DataWriterStops writing the array started with the last call toDataWriter.beginObject().- Specified by:
endArrayin interfaceDataWriter- Throws:
IOException- If writing fails.
-
name
public void name(int id) throws IOExceptionDescription copied from interface:DataWriterWrites an identifier of a field fo the currently written object.- Specified by:
namein interfaceDataWriter- Throws:
IOException- If writing fails.
-
value
public void value(int value) throws IOExceptionDescription copied from interface:DataWriterWrites an unsignedintvalue.- Specified by:
valuein interfaceDataWriter- Throws:
IOException- If writing fails.
-
valueSigned
public void valueSigned(int value) throws IOExceptionDescription copied from interface:DataWriterWrites a signedintvalue.- Specified by:
valueSignedin interfaceDataWriter- Throws:
IOException- If writing fails.
-
valueFixed
public void valueFixed(int value) throws IOExceptionDescription copied from interface:DataWriterWrites a fixed size 32 bitintvalue.- Specified by:
valueFixedin interfaceDataWriter- Throws:
IOException- If writing fails.
-
value
public void value(float value) throws IOExceptionDescription copied from interface:DataWriterWrites afloatvalue.- Specified by:
valuein interfaceDataWriter- Throws:
IOException- If writing fails.
-
value
public void value(long value) throws IOExceptionDescription copied from interface:DataWriterWrites an unsignedlongvalue.- Specified by:
valuein interfaceDataWriter- Throws:
IOException- If writing fails.
-
valueSigned
public void valueSigned(long value) throws IOExceptionDescription copied from interface:DataWriterWrites a signedlongvalue.- Specified by:
valueSignedin interfaceDataWriter- Throws:
IOException- If writing fails.
-
valueFixed
public void valueFixed(long value) throws IOExceptionDescription copied from interface:DataWriterWrites a fixed size 64 bitlongvalue.- Specified by:
valueFixedin interfaceDataWriter- Throws:
IOException- If writing fails.
-
value
public void value(double value) throws IOExceptionDescription copied from interface:DataWriterWrites adoublevalue.- Specified by:
valuein interfaceDataWriter- Throws:
IOException- If writing fails.
-
value
public void value(byte[] value) throws IOExceptionDescription copied from interface:DataWriterWrites a binary string value.- Specified by:
valuein interfaceDataWriter- Throws:
IOException- If writing fails.
-
valueBinaryStream
public OutputStream valueBinaryStream() throws IOException
Description copied from interface:DataWriterStarts writing a binary value of arbitrary length in chunked mode.The binary contents must be written the the resulting
OutputStream. No other methods of thisDataWritermust be called before the resultingOutputStreamhas beenclosed.- Specified by:
valueBinaryStreamin interfaceDataWriter- Throws:
IOException- If writing fails.
-
value
public void value(String value) throws IOException
Description copied from interface:DataWriterWrites aStringvalue inutf-8encoding.- Specified by:
valuein interfaceDataWriter- Throws:
IOException- If writing fails.
-
-