Package net.dona.doip
Class InDoipSegmentFromInputStream
- java.lang.Object
-
- net.dona.doip.InDoipSegmentFromInputStream
-
- All Implemented Interfaces:
InDoipSegment
public class InDoipSegmentFromInputStream extends java.lang.Object implements InDoipSegment
An implementation ofInDoipSegmentproduced from in input stream; may be either a JSON segment or a bytes segment.
-
-
Constructor Summary
Constructors Constructor Description InDoipSegmentFromInputStream(boolean isJson, java.io.InputStream in)Constructs anInDoipSegmentfrom an input stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.InputStreamgetInputStream()Returns an input stream, for either a JSON segment or a bytes segment.com.google.gson.JsonElementgetJson()Returns the JSON of a JSON segmentbooleanisJson()Returns true if this is a JSON segment, false if this is a bytes segment.
-
-
-
Constructor Detail
-
InDoipSegmentFromInputStream
public InDoipSegmentFromInputStream(boolean isJson, java.io.InputStream in)Constructs anInDoipSegmentfrom an input stream.- Parameters:
isJson- whether this will be a JSON segmentin- an input stream supplying the bytes of the segment
-
-
Method Detail
-
isJson
public boolean isJson()
Description copied from interface:InDoipSegmentReturns true if this is a JSON segment, false if this is a bytes segment.- Specified by:
isJsonin interfaceInDoipSegment- Returns:
- true if this is a JSON segment, otherwise false
-
getInputStream
public java.io.InputStream getInputStream()
Description copied from interface:InDoipSegmentReturns an input stream, for either a JSON segment or a bytes segment.- Specified by:
getInputStreamin interfaceInDoipSegment- Returns:
- an input stream containing the bytes from the segment (including a serialization of a JSON segment)
-
getJson
public com.google.gson.JsonElement getJson() throws java.io.IOExceptionDescription copied from interface:InDoipSegmentReturns the JSON of a JSON segment- Specified by:
getJsonin interfaceInDoipSegment- Returns:
- the JSON of a JSON segment
- Throws:
java.io.IOException- if there is a JSON parsing error
-
-