public class Hl7InputStreamMessageIterator extends HapiContextSupport implements Iterator<Message>
Reads from an InputStream
containing a stream of encoded HL7 messages
and iterates over those messages. This class is geared towards reading from
files, and tries to be very lenient about the format of the stream,
specifically concerning control characters and line endings. It should be
safe to provide a stream containing Windows or Unix line endings (which will
be treated as segment delimiters). It is also safe to provide a stream containing
MLLP control blocks before and after each message (although these will not be
validated! Do not use this class to read MLLP messages from a socket stream!)
The input stream could, for example, be a FileInputStream reading from a text file containing a number of HL7 messages in plain text format.
Usage note: If an IOException occurs while reading from the stream or a
message parsing exception occurs, it will be thrown as an unchecked
Hl7InputStreamMessageStringIterator.ParseFailureError
Constructor and Description |
---|
Hl7InputStreamMessageIterator(InputStream theInputStream)
Constructor
|
Hl7InputStreamMessageIterator(InputStream theInputStream,
HapiContext theHapiContext)
Constructor
|
Hl7InputStreamMessageIterator(Reader theReader)
Constructor
|
Hl7InputStreamMessageIterator(Reader theReader,
HapiContext theHapiContext)
Constructor
|
Modifier and Type | Method and Description |
---|---|
static Hl7InputStreamMessageIterator |
getForClasspathResource(String theClasspath)
Factory method which returns an instance which reads from a file on the
classpath
|
boolean |
hasNext() |
Message |
next() |
void |
remove()
Unsupported method!
|
void |
setIgnoreComments(boolean theIgnoreComments)
If set to true, any lines beginning with a hash (#) will be ignored.
|
void |
setMessageType(Class<? extends Message> theMessageType)
If set (default is
null ), all messages will be parsed into
instances of this type. |
getHapiContext, setHapiContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
public Hl7InputStreamMessageIterator(InputStream theInputStream)
theInputStream
- The input stream to read frompublic Hl7InputStreamMessageIterator(Reader theReader)
theReader
- The reader to read frompublic Hl7InputStreamMessageIterator(InputStream theInputStream, HapiContext theHapiContext)
theInputStream
- The input stream to read fromtheHapiContext
- The HapiContext from which to obtain the parserpublic Hl7InputStreamMessageIterator(Reader theReader, HapiContext theHapiContext)
theReader
- The reader to read fromtheHapiContext
- The HapiContext from which to obtain the parserpublic static Hl7InputStreamMessageIterator getForClasspathResource(String theClasspath)
public void remove()
remove
in interface Iterator<Message>
UnsupportedOperationException
- If calledpublic void setIgnoreComments(boolean theIgnoreComments)
public void setMessageType(Class<? extends Message> theMessageType)
null
), all messages will be parsed into
instances of this type.Copyright © 2001–2017 University Health Network. All rights reserved.