org.urhl7.spark
Class SparkFileWriter

java.lang.Object
  extended by org.urhl7.spark.SparkFileWriter

public class SparkFileWriter
extends Object

Allows the writing of HL7Structure messages to a specified file.


Field Summary
static String DELIMITER_DEFAULT
          The default delimiter between messages.
 
Constructor Summary
SparkFileWriter(File outputFile)
          Creates a SparkFileWriter, mapped to a specific File.
SparkFileWriter(File outputFile, boolean appendToFile)
          Creates a SparkFileWriter, mapped to a file.
SparkFileWriter(File outputFile, String delimiter)
          Creates a SparkFileWriter, mapped to a file, with a specified delimiter.
SparkFileWriter(File outputFile, String delimiter, boolean appendToFile)
          Creates a SparkFileWriter, mapped to a file.
 
Method Summary
 void close()
          Closes the underlying FileWriter.
 String getDelimiter()
          Returns the delimiters to use after each message.
 File getOutputFile()
          Returns the output file that is being written to
 boolean isAppendToFile()
          Will this append or Overwrite file.
 void setAppendToFile(boolean appendToFile)
          Appends or Overwrites file.
 void setDelimiter(String delimiter)
          Sets the delimiter to use after each message
 void setOutputFile(File outputFile)
          Sets the output file to write to
 void write(HL7Structure message)
          Writes an HL7Structure message to the file specified, immediately followed by the delimiter.
 void writeAll(List<HL7Structure> messages)
          Writes several HL7Structure messages to the file, each ended with the specified delimiter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DELIMITER_DEFAULT

public static final String DELIMITER_DEFAULT
The default delimiter between messages. The default value is "\r\n"

See Also:
Constant Field Values
Constructor Detail

SparkFileWriter

public SparkFileWriter(File outputFile)
                throws IOException
Creates a SparkFileWriter, mapped to a specific File. Default delimiters are used, and the file will be APPENDED to if it already exists

Parameters:
outputFile - the file to write data to.
Throws:
IOException

SparkFileWriter

public SparkFileWriter(File outputFile,
                       String delimiter)
                throws IOException
Creates a SparkFileWriter, mapped to a file, with a specified delimiter. The file will be APPENDED to if it already exists.

Parameters:
outputFile - the file to write data to.
delimiter - the delimiter that will be placed after every message.
Throws:
IOException

SparkFileWriter

public SparkFileWriter(File outputFile,
                       boolean appendToFile)
                throws IOException
Creates a SparkFileWriter, mapped to a file. Messages will be appended or will overwrite the file depending on the appendToFile boolean. Default delimiters will be used.

Parameters:
outputFile - the file to write data to.
appendToFile - true to append to the file, false to overwrite the file.
Throws:
IOException

SparkFileWriter

public SparkFileWriter(File outputFile,
                       String delimiter,
                       boolean appendToFile)
                throws IOException
Creates a SparkFileWriter, mapped to a file. Uses the specified delimiters, and will append or overwrite the file.

Parameters:
outputFile - the file to write data to.
delimiter - the delimiters that are after every message in the file.
appendToFile - true to append to the file, false to overwrite the file.
Throws:
IOException
Method Detail

write

public void write(HL7Structure message)
           throws IOException
Writes an HL7Structure message to the file specified, immediately followed by the delimiter.

Parameters:
message -
Throws:
IOException

writeAll

public void writeAll(List<HL7Structure> messages)
              throws IOException
Writes several HL7Structure messages to the file, each ended with the specified delimiter.

Parameters:
messages -
Throws:
IOException

close

public void close()
           throws IOException
Closes the underlying FileWriter. If you call this method and attempt to write again, you will receive an IOException. Remember to close() when complete with your writing to file to avoid locks.

Throws:
IOException

getOutputFile

public File getOutputFile()
Returns the output file that is being written to

Returns:
the outputFile

setOutputFile

public void setOutputFile(File outputFile)
                   throws IOException
Sets the output file to write to

Parameters:
outputFile - the outputFile to set
Throws:
IOException

getDelimiter

public String getDelimiter()
Returns the delimiters to use after each message.

Returns:
the delimiter

setDelimiter

public void setDelimiter(String delimiter)
Sets the delimiter to use after each message

Parameters:
delimiter - the delimiter to set

isAppendToFile

public boolean isAppendToFile()
Will this append or Overwrite file. True appends, False means overwrite

Returns:
the appendToFile

setAppendToFile

public void setAppendToFile(boolean appendToFile)
                     throws IOException
Appends or Overwrites file. True appends, False means overwrite

Parameters:
appendToFile - the appendToFile to set
Throws:
IOException