org.gedcomx.util
Class RecordSetWriter

java.lang.Object
  extended by org.gedcomx.util.RecordSetWriter

public class RecordSetWriter
extends Object

Class for streaming a RecordSet to an OutputStream in XML as records are being added. User: Randy Wilson Date: 12/4/13


Constructor Summary
  RecordSetWriter(OutputStream outputStream)
          Constructor.
protected RecordSetWriter(OutputStream outputStream, boolean shouldFilter)
          Constructor.
 
Method Summary
 void close()
          Finish writing the file, including metadata (if set), and the closing tag.
 void setMetadata(Gedcomx metadata)
          Set the 'metadata' document, which will be written after all of the records.
 void writeRecord(Gedcomx record)
          Write the given record to the underlying byte-level (and possibly GZipped) output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RecordSetWriter

public RecordSetWriter(OutputStream outputStream)
Constructor. Prepares to write GedcomX document records to the given output stream (which may well be a GZIPOutputStream), so that only one such document needs to be fully instantiated in memory at once.

Parameters:
outputStream - - OutputStream to write XML to.

RecordSetWriter

protected RecordSetWriter(OutputStream outputStream,
                          boolean shouldFilter)
Constructor. Prepares to write GedcomX document records to the given output stream (which may well be a GZIPOutputStream), so that only one such document needs to be fully instantiated in memory at once.

Parameters:
outputStream - - OutputStream to write XML to.
shouldFilter - - Flag for whether to use a CleanXMLStreamWriter to convert invalid XML characters (such as a vertical tab) into the Unicode REPLACEMENT_CHARACTER (0xFFFD), so that the XML will unmarshal without throwing an exception.
Method Detail

writeRecord

public void writeRecord(Gedcomx record)
                 throws JAXBException
Write the given record to the underlying byte-level (and possibly GZipped) output stream.

Parameters:
record - - GedcomX document to add as a 'record' to the RecordSet OutputStream.
Throws:
JAXBException

setMetadata

public void setMetadata(Gedcomx metadata)
                 throws JAXBException
Set the 'metadata' document, which will be written after all of the records. Often used for the collection-level information such as collection source descriptions, record descriptors, etc. May describe a collection that goes beyond the records contained within this same GedcomX RecordSet.

Parameters:
metadata - - GedcomX document with group-level information.
Throws:
JAXBException

close

public void close()
           throws IOException
Finish writing the file, including metadata (if set), and the closing tag. Closes the writers and output stream.

Throws:
IOException


Copyright © 2015. All rights reserved.