ca.uhn.hl7v2.util
Class Hl7InputStreamMessageStringIterator

java.lang.Object
  extended by ca.uhn.hl7v2.util.Hl7InputStreamMessageStringIterator
All Implemented Interfaces:
Iterator<String>

public class Hl7InputStreamMessageStringIterator
extends Object
implements Iterator<String>

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


Nested Class Summary
static class Hl7InputStreamMessageStringIterator.ParseFailureError
           
 
Constructor Summary
Hl7InputStreamMessageStringIterator(InputStream theInputStream)
          Constructor
Hl7InputStreamMessageStringIterator(Reader theReader)
          Constructor
 
Method Summary
 boolean hasNext()
          
 String next()
          
 void remove()
          Unsupported method!
 void setIgnoreComments(boolean theIgnoreComments)
          If set to true, any lines beginning with a hash (#) will be ignored.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Hl7InputStreamMessageStringIterator

public Hl7InputStreamMessageStringIterator(InputStream theInputStream)
Constructor

Parameters:
theInputStream - The input stream to read from

Hl7InputStreamMessageStringIterator

public Hl7InputStreamMessageStringIterator(Reader theReader)
Constructor

Parameters:
theReader - The reader to read from
Method Detail

hasNext

public boolean hasNext()

Specified by:
hasNext in interface Iterator<String>

next

public String next()

Specified by:
next in interface Iterator<String>

remove

public void remove()
Unsupported method!

Specified by:
remove in interface Iterator<String>
Throws:
UnsupportedOperationException - If called

setIgnoreComments

public void setIgnoreComments(boolean theIgnoreComments)
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.



Copyright © 2001-2012 University Health Network. All Rights Reserved.