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
Packaging logic for XML Documents. Package an XML with all references in a ZIP Package.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumZIP Compression Level. -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new AbstractXmlPackager.AbstractXmlPackager(Path zipPath, OutputStream out) Create a new AbstractXmlPackager. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the validation value.protected final voidpackageXml(T document, 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.final voidsetCompressionLevel(AbstractXmlPackager.CompressionLevel compressionLevel) Setter for compressionLevel attribute.voidsetValidation(boolean validation) Setter for validation attribute.final AbstractXmlPackager<T>withZipPath(Path zipPath) Sets a reference to an already existing archive.
-
Constructor Details
-
AbstractXmlPackager
Create a new AbstractXmlPackager.- Parameters:
out- The underlying OutputStream to write the package to.
-
AbstractXmlPackager
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
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
Setter for compressionLevel attribute.- Parameters:
compressionLevel- the compressionLevel to set
-
packageXml
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
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.
-