Class AbstractXmlPackager<T>

java.lang.Object
org.cip4.lib.xjdf.xml.internal.AbstractXmlPackager<T>
Type Parameters:
T - Object type to create the abstract xml packager for.
Direct Known Subclasses:
XJdfPackager

public abstract class AbstractXmlPackager<T> extends Object
Packaging logic for XML Documents. Package an XML with all references in a ZIP Package.
  • Constructor Details

    • AbstractXmlPackager

      public AbstractXmlPackager(OutputStream out)
      Create a new AbstractXmlPackager.
      Parameters:
      out - The underlying OutputStream to write the package to.
    • AbstractXmlPackager

      public AbstractXmlPackager(Path zipPath, OutputStream out)
      Create a new AbstractXmlPackager.
      Parameters:
      zipPath - The path to an existing zip archive.
      out - The underlying OutputStream to write the package to.
  • Method Details

    • withZipPath

      public final AbstractXmlPackager<T> withZipPath(Path zipPath)
      Sets a reference to an already existing archive.
      Parameters:
      zipPath - The path to existing archive
      Returns:
      This AbstractXmlPackager
    • isValidation

      public boolean isValidation()
      Returns the validation value.
      Returns:
      True in case the docuemnt should become validated before packaging.
    • setValidation

      public void setValidation(boolean validation)
      Setter for validation attribute.
      Parameters:
      validation - True in case the XML should become validated before packaging.
    • setCompressionLevel

      public final void setCompressionLevel(AbstractXmlPackager.CompressionLevel compressionLevel)
      Setter for compressionLevel attribute.
      Parameters:
      compressionLevel - the compressionLevel to set
    • packageXml

      protected final void packageXml(T document, String docName) throws PackagerException
      Packages an XML document to a zipped binary output stream.
      Parameters:
      document - Document to package.
      docName - File name of the document in the zip package.
      Throws:
      PackagerException - If the XML document could not be packaged.
    • parseDocument

      protected abstract byte[] parseDocument(T document, boolean validation) throws Exception
      Parses an XML document into a byte array.
      Parameters:
      document - XML document to parse.
      validation - true, in case XML validation should be validated before packaging.
      Returns:
      Parsed document as byte array.
      Throws:
      Exception - If parsing fails.