Package org.cip4.lib.xjdf.xml.internal
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 java.lang.ObjectPackaging logic for XML Documents. Package an XML with all references in a ZIP Package.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractXmlPackager.CompressionLevelZIP Compression Level.
-
Constructor Summary
Constructors Constructor Description AbstractXmlPackager(java.io.OutputStream out)Create a new AbstractXmlPackager.AbstractXmlPackager(java.nio.file.Path zipPath, java.io.OutputStream out)Create a new AbstractXmlPackager.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanisValidation()Returns the validation value.protected voidpackageXml(T document, java.lang.String docName)Packages an XML document to a zipped binary output stream.protected abstract byte[]parseDocument(T document, boolean validation)Parses an XML document into a byte array.voidsetCompressionLevel(AbstractXmlPackager.CompressionLevel compressionLevel)Setter for compressionLevel attribute.voidsetValidation(boolean validation)Setter for validation attribute.AbstractXmlPackager<T>withZipPath(java.nio.file.Path zipPath)Sets a reference to an already existing archive.
-
-
-
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.
-
-