Class RecordSetWriter

java.lang.Object
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 Details

    • 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. This constructor includes only Gedcomx.class and RecordSet.class in the underlying JAXBContext marshaller.
      Parameters:
      outputStream - - OutputStream to write XML to.
    • RecordSetWriter

      public RecordSetWriter(OutputStream outputStream, Class... marshallerClasses)
      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. Only the supplied list of Classes will be included in the JAXBContext marshaller.
      Parameters:
      outputStream - - OutputStream to write XML to.
      marshallerClasses - - A list of Classes to include in the underlying JAXBContext marshaller.
    • RecordSetWriter

      protected RecordSetWriter(OutputStream outputStream, boolean shouldFilter, Class... marshallerClasses)
      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. Only the supplied list of Classes will be included in the JAXBContext marshaller.
      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.
      marshallerClasses - - A list of Classes to include in the underlying JAXBContext marshaller.
  • Method Details

    • writeRecord

      public void writeRecord(Gedcomx record) throws jakarta.xml.bind.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:
      jakarta.xml.bind.JAXBException - If there's a problem with the XML.
    • setMetadata

      public void setMetadata(Gedcomx metadata) throws jakarta.xml.bind.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:
      jakarta.xml.bind.JAXBException - If there's a problem with the XML.
    • 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 - If there's an I/O problem.