Package org.dellroad.hl7.llp
Class LLPInputStream
- java.lang.Object
-
- org.dellroad.hl7.llp.LLPInputStream
-
-
Constructor Summary
Constructors Constructor Description LLPInputStream(InputStream input, int maxLength)Constructor for whenStandardCharsets.ISO_8859_1character encoding is to be used for all messages.LLPInputStream(InputStream input, Charset charset, int maxLength)Constructor for when a fixed character encoding is to be used for all messages.LLPInputStream(InputStream input, CharsetDecoder charsetDecoder, int maxLength)Primary constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the underlying stream.HL7MessagereadMessage()Read next message from the underlying stream.voidskip()Advance past the end of the current message.
-
-
-
Constructor Detail
-
LLPInputStream
public LLPInputStream(InputStream input, int maxLength)
Constructor for whenStandardCharsets.ISO_8859_1character encoding is to be used for all messages.Equivalent to:
LLPInputStream(input,StandardCharsets.ISO_8859_1, maxLength).- Parameters:
input- underlying input streammaxLength- maximum allowed message length- Throws:
IllegalArgumentException- ifinputis nullIllegalArgumentException- if maxLength is negative
-
LLPInputStream
public LLPInputStream(InputStream input, Charset charset, int maxLength)
Constructor for when a fixed character encoding is to be used for all messages.- Parameters:
input- underlying input streammaxLength- maximum allowed message lengthcharset- character encoding for messages- Throws:
IllegalArgumentException- if any parameter is nullIllegalArgumentException- if maxLength is negative
-
LLPInputStream
public LLPInputStream(InputStream input, CharsetDecoder charsetDecoder, int maxLength)
Primary constructor.- Parameters:
input- underlying input streammaxLength- maximum allowed message lengthcharsetDecoder- determines the character encoding for each incoming message- Throws:
IllegalArgumentException- if any parameter is nullIllegalArgumentException- if maxLength is negative
-
-
Method Detail
-
readMessage
public HL7Message readMessage() throws IOException, HL7ContentException
Read next message from the underlying stream.- Specified by:
readMessagein interfaceHL7Reader- Returns:
- next message read
- Throws:
EOFException- if there is no more inputHL7ContentException- if a malformed message is readLLPException- if illegal framing byte(s) are read from the underlying stream, or the message is too longIOException- if an error occurs on the underlying stream
-
skip
public void skip() throws IOExceptionAdvance past the end of the current message. This method can be used (for example) to skip over the remaining portion of a badly framed message that resulted in aLLPExceptionin an attempt to salvage the connection.This method just reads until the next occurrence of a
LLPConstants.TRAILING_BYTE_0byte followed immediately by aLLPConstants.TRAILING_BYTE_1byte, then returns.- Throws:
EOFException- if there is no more inputIOException- if an error occurs on the underlying stream
-
close
public void close() throws IOExceptionClose the underlying stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
-