zugferdimporter to accept xml files

This commit is contained in:
jstaerk
2024-03-31 20:21:39 +02:00
parent 15122e809d
commit df0eef061f
2 changed files with 52 additions and 26 deletions

View File

@@ -1,5 +1,7 @@
- EN16931 validation 1.3.11 codelists v11 #357
- Fonts removed #358
- xrechnungimporter to read from filename, inputstream
- zugferdimporter to accept xml files
2.10.0
=======

View File

@@ -1,6 +1,9 @@
package org.mustangproject;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.AbstractList;
@@ -25,22 +28,27 @@ public class XMLTools extends XMLWriter {
}
public static List<Node> asList(NodeList n) {
return n.getLength()==0?
Collections.<Node>emptyList(): new NodeListWrapper(n);
return n.getLength() == 0 ?
Collections.<Node>emptyList() : new NodeListWrapper(n);
}
static final class NodeListWrapper extends AbstractList<Node>
implements RandomAccess {
private final NodeList list;
NodeListWrapper(NodeList l) {
list=l;
list = l;
}
public Node get(int index) {
return list.item(index);
}
public int size() {
return list.getLength();
}
}
public static String nDigitFormat(BigDecimal value, int scale) {
/*
* I needed 123,45, locale independent.I tried
@@ -159,5 +167,21 @@ public class XMLTools extends XMLWriter {
return zugferdData;
}
public static byte[] getBytesFromStream(InputStream fileinput) throws IOException {
// we're on java 8 so we cant use inputstream.readallbytes
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int nRead;
byte[] data = new byte[16384];
BufferedInputStream bufferedInput=new BufferedInputStream(fileinput);
while ((nRead = bufferedInput.read(data, 0, data.length)) != -1) {
buffer.write(data, 0, nRead);
}
return buffer.toByteArray();
// end of polyfill
}
}