Create XRechnungImporter to import data from raw xml

The XRechnungImporter extends from ZUGFeRDImporter.
It simply sets the given raw xml and provides otherwise the same functionality as the parent class.
This commit is contained in:
Sebastian Sieber
2020-11-24 14:54:21 +01:00
parent cda1cd1c24
commit 451b249887
2 changed files with 26 additions and 1 deletions

View File

@@ -0,0 +1,21 @@
package org.mustangproject.ZUGFeRD;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class XRechnungImporter extends ZUGFeRDImporter {
public XRechnungImporter(byte[] rawXml) {
super();
try {
setRawXML(rawXml);
containsMeta = true;
} catch (final IOException e) {
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
throw new ZUGFeRDExportException(e);
}
}
}

View File

@@ -48,7 +48,7 @@ public class ZUGFeRDImporter {
/** /**
* if metadata has been found * if metadata has been found
*/ */
private boolean containsMeta = false; protected boolean containsMeta = false;
/** /**
* map filenames of additional XML files to their contents * map filenames of additional XML files to their contents
*/ */
@@ -67,6 +67,10 @@ public class ZUGFeRDImporter {
private Document document; private Document document;
protected ZUGFeRDImporter() {
//constructor for extending classes
}
public ZUGFeRDImporter(String pdfFilename) { public ZUGFeRDImporter(String pdfFilename) {
try (InputStream bis = Files.newInputStream(Paths.get(pdfFilename), StandardOpenOption.READ)) { try (InputStream bis = Files.newInputStream(Paths.get(pdfFilename), StandardOpenOption.READ)) {
extractLowLevel(bis); extractLowLevel(bis);