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 ofOutDoipMessage
which writes a serialized DOIP message into anOutputStream
.
-
-
Constructor Summary
Constructors Constructor Description OutDoipMessageImpl(java.io.OutputStream out)
Constructs anOutDoipMessage
which will write a serialized DOIP message into the suppliedOutputStream
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
closeSegmentOutput()
Closes the particular segment currently being written, if anyjava.io.OutputStream
getBytesOutputStream()
Returns anOutputStream
that can be used to write to a bytes segment.java.io.Writer
getJsonWriter()
Returns aWriter
that can be used to write to a JSON segment.void
writeBytes(byte[] bytes)
Writes a bytes segment into the outgoing message.void
writeBytes(java.io.InputStream in)
Writes a bytes segment into the outgoing message.void
writeJson(byte[] json)
Writes a JSON segment into the outgoing message.void
writeJson(com.google.gson.JsonElement json)
Writes a JSON segment into the outgoing message.void
writeJson(java.lang.String json)
Writes a JSON segment into the outgoing message.
-
-
-
Constructor Detail
-
OutDoipMessageImpl
public OutDoipMessageImpl(java.io.OutputStream out)
Constructs anOutDoipMessage
which 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.IOException
Description copied from interface:OutDoipMessage
Writes a JSON segment into the outgoing message.- Specified by:
writeJson
in interfaceOutDoipMessage
- Parameters:
json
- the json to be written- Throws:
java.io.IOException
-
writeJson
public void writeJson(java.lang.String json) throws java.io.IOException
Description copied from interface:OutDoipMessage
Writes a JSON segment into the outgoing message.- Specified by:
writeJson
in interfaceOutDoipMessage
- Parameters:
json
- the json to be written- Throws:
java.io.IOException
-
writeJson
public void writeJson(byte[] json) throws java.io.IOException
Description copied from interface:OutDoipMessage
Writes a JSON segment into the outgoing message.- Specified by:
writeJson
in interfaceOutDoipMessage
- Parameters:
json
- the json to be written- Throws:
java.io.IOException
-
getJsonWriter
public java.io.Writer getJsonWriter()
Description copied from interface:OutDoipMessage
Returns aWriter
that can be used to write to a JSON segment.- Specified by:
getJsonWriter
in interfaceOutDoipMessage
- Returns:
- a
Writer
that can be used to write to a JSON segment
-
writeBytes
public void writeBytes(byte[] bytes) throws java.io.IOException
Description copied from interface:OutDoipMessage
Writes a bytes segment into the outgoing message.- Specified by:
writeBytes
in interfaceOutDoipMessage
- Parameters:
bytes
- the bytes the be written- Throws:
java.io.IOException
-
writeBytes
public void writeBytes(java.io.InputStream in) throws java.io.IOException
Description copied from interface:OutDoipMessage
Writes a bytes segment into the outgoing message.- Specified by:
writeBytes
in 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.IOException
Description copied from interface:OutDoipMessage
Returns anOutputStream
that can be used to write to a bytes segment.- Specified by:
getBytesOutputStream
in interfaceOutDoipMessage
- Returns:
- an
OutputStream
that can be used to write to a bytes segment - Throws:
java.io.IOException
-
closeSegmentOutput
public void closeSegmentOutput() throws java.io.IOException
Closes the particular segment currently being written, if any- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceOutDoipMessage
- Throws:
java.io.IOException
-
-