Make ZUGFeRDExporter closeable, so that the underlying PDDocument can be closed without violating the law of demeter

This commit is contained in:
Yannik Hampe
2017-05-09 18:43:19 +02:00
parent d6dae1d0c3
commit 133857bd66

View File

@@ -11,6 +11,7 @@ package org.mustangproject.ZUGFeRD;
*/
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -62,7 +63,7 @@ import org.apache.xmpbox.type.BadFieldValueException;
import org.apache.xmpbox.xml.XmpSerializer;
import org.mustangproject.ZUGFeRD.model.*;
public class ZUGFeRDExporter {
public class ZUGFeRDExporter implements Closeable {
/**
* * You will need Apache PDFBox. To use the ZUGFeRD exporter, implement
@@ -539,6 +540,12 @@ public class ZUGFeRDExporter {
return cat;
}
public void close() throws IOException {
if (doc != null) {
doc.close();
}
}
private static final ObjectFactory xmlFactory = new ObjectFactory();
private final JAXBContext jaxbContext;
private final Marshaller marshaller;