Package net.dona.doip
Class OutDoipMessageImpl
- java.lang.Object
-
- net.dona.doip.OutDoipMessageImpl
-
- All Implemented Interfaces:
java.lang.AutoCloseable,OutDoipMessage
public class OutDoipMessageImpl extends java.lang.Object implements OutDoipMessage
An implementation ofOutDoipMessagewhich writes a serialized DOIP message into anOutputStream.
-
-
Constructor Summary
Constructors Constructor Description OutDoipMessageImpl(java.io.OutputStream out)Constructs anOutDoipMessagewhich will write a serialized DOIP message into the suppliedOutputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidcloseSegmentOutput()Closes the particular segment currently being written, if anyjava.io.OutputStreamgetBytesOutputStream()Returns anOutputStreamthat can be used to write to a bytes segment.java.io.WritergetJsonWriter()Returns aWriterthat can be used to write to a JSON segment.voidwriteBytes(byte[] bytes)Writes a bytes segment into the outgoing message.voidwriteBytes(java.io.InputStream in)Writes a bytes segment into the outgoing message.voidwriteJson(byte[] json)Writes a JSON segment into the outgoing message.voidwriteJson(com.google.gson.JsonElement json)Writes a JSON segment into the outgoing message.voidwriteJson(java.lang.String json)Writes a JSON segment into the outgoing message.
-
-
-
Constructor Detail
-
OutDoipMessageImpl
public OutDoipMessageImpl(java.io.OutputStream out)
Constructs anOutDoipMessagewhich will write a serialized DOIP message into the suppliedOutputStream.- Parameters:
out- the stream into which to write the serialized DOIP message
-
-
Method Detail
-
writeJson
public void writeJson(com.google.gson.JsonElement json) throws java.io.IOExceptionDescription copied from interface:OutDoipMessageWrites a JSON segment into the outgoing message.- Specified by:
writeJsonin interfaceOutDoipMessage- Parameters:
json- the json to be written- Throws:
java.io.IOException
-
writeJson
public void writeJson(java.lang.String json) throws java.io.IOExceptionDescription copied from interface:OutDoipMessageWrites a JSON segment into the outgoing message.- Specified by:
writeJsonin interfaceOutDoipMessage- Parameters:
json- the json to be written- Throws:
java.io.IOException
-
writeJson
public void writeJson(byte[] json) throws java.io.IOExceptionDescription copied from interface:OutDoipMessageWrites a JSON segment into the outgoing message.- Specified by:
writeJsonin interfaceOutDoipMessage- Parameters:
json- the json to be written- Throws:
java.io.IOException
-
getJsonWriter
public java.io.Writer getJsonWriter()
Description copied from interface:OutDoipMessageReturns aWriterthat can be used to write to a JSON segment.- Specified by:
getJsonWriterin interfaceOutDoipMessage- Returns:
- a
Writerthat can be used to write to a JSON segment
-
writeBytes
public void writeBytes(byte[] bytes) throws java.io.IOExceptionDescription copied from interface:OutDoipMessageWrites a bytes segment into the outgoing message.- Specified by:
writeBytesin interfaceOutDoipMessage- Parameters:
bytes- the bytes the be written- Throws:
java.io.IOException
-
writeBytes
public void writeBytes(java.io.InputStream in) throws java.io.IOExceptionDescription copied from interface:OutDoipMessageWrites a bytes segment into the outgoing message.- Specified by:
writeBytesin interfaceOutDoipMessage- Parameters:
in- an input stream from which bytes will be read and written to the outgoing bytes segment- Throws:
java.io.IOException
-
getBytesOutputStream
public java.io.OutputStream getBytesOutputStream() throws java.io.IOExceptionDescription copied from interface:OutDoipMessageReturns anOutputStreamthat can be used to write to a bytes segment.- Specified by:
getBytesOutputStreamin interfaceOutDoipMessage- Returns:
- an
OutputStreamthat can be used to write to a bytes segment - Throws:
java.io.IOException
-
closeSegmentOutput
public void closeSegmentOutput() throws java.io.IOExceptionCloses the particular segment currently being written, if any- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceOutDoipMessage- Throws:
java.io.IOException
-
-