Class Hl7InputStreamMessageIterator
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 Summary
ConstructorsConstructorDescriptionHl7InputStreamMessageIterator(InputStream theInputStream) ConstructorHl7InputStreamMessageIterator(InputStream theInputStream, HapiContext theHapiContext) ConstructorHl7InputStreamMessageIterator(Reader theReader) ConstructorHl7InputStreamMessageIterator(Reader theReader, HapiContext theHapiContext) Constructor -
Method Summary
Modifier and TypeMethodDescriptiongetForClasspathResource(String theClasspath) Factory method which returns an instance which reads from a file on the classpathbooleanhasNext()next()voidremove()Unsupported method!voidsetIgnoreComments(boolean theIgnoreComments) If set to true, any lines beginning with a hash (#) will be ignored.voidsetMessageType(Class<? extends Message> theMessageType) If set (default isnull), all messages will be parsed into instances of this type.Methods inherited from class ca.uhn.hl7v2.HapiContextSupport
getHapiContext, setHapiContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
Hl7InputStreamMessageIterator
Constructor- Parameters:
theInputStream- The input stream to read from
-
Hl7InputStreamMessageIterator
Constructor- Parameters:
theReader- The reader to read from
-
Hl7InputStreamMessageIterator
Constructor- Parameters:
theInputStream- The input stream to read fromtheHapiContext- The HapiContext from which to obtain the parser
-
Hl7InputStreamMessageIterator
Constructor- Parameters:
theReader- The reader to read fromtheHapiContext- The HapiContext from which to obtain the parser
-
-
Method Details
-
getForClasspathResource
Factory method which returns an instance which reads from a file on the classpath -
hasNext
-
next
-
remove
Unsupported method!- Specified by:
removein interfaceIterator<Message>- Throws:
UnsupportedOperationException- If called
-
setIgnoreComments
If set to true, any lines beginning with a hash (#) will be ignored. This allows you to place comments in a file to be read if needed. -
setMessageType
If set (default isnull), all messages will be parsed into instances of this type.
-