Class AbstractXmlPackager<T>

  • Type Parameters:
    T - Object type to create the abstract xml packager for.
    Direct Known Subclasses:
    XJdfPackager

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

      • AbstractXmlPackager

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

        public AbstractXmlPackager​(java.nio.file.Path zipPath,
                                   java.io.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 Detail

      • withZipPath

        public final AbstractXmlPackager<T> withZipPath​(java.nio.file.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,
                                        java.lang.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 java.lang.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:
        java.lang.Exception - If parsing fails.