zugferdimporter to accept xml files
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
- EN16931 validation 1.3.11 codelists v11 #357
|
- EN16931 validation 1.3.11 codelists v11 #357
|
||||||
- Fonts removed #358
|
- Fonts removed #358
|
||||||
|
- xrechnungimporter to read from filename, inputstream
|
||||||
|
- zugferdimporter to accept xml files
|
||||||
|
|
||||||
2.10.0
|
2.10.0
|
||||||
=======
|
=======
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package org.mustangproject;
|
package org.mustangproject;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.util.AbstractList;
|
import java.util.AbstractList;
|
||||||
@@ -28,19 +31,24 @@ public class XMLTools extends XMLWriter {
|
|||||||
return n.getLength() == 0 ?
|
return n.getLength() == 0 ?
|
||||||
Collections.<Node>emptyList() : new NodeListWrapper(n);
|
Collections.<Node>emptyList() : new NodeListWrapper(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static final class NodeListWrapper extends AbstractList<Node>
|
static final class NodeListWrapper extends AbstractList<Node>
|
||||||
implements RandomAccess {
|
implements RandomAccess {
|
||||||
private final NodeList list;
|
private final NodeList list;
|
||||||
|
|
||||||
NodeListWrapper(NodeList l) {
|
NodeListWrapper(NodeList l) {
|
||||||
list = l;
|
list = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Node get(int index) {
|
public Node get(int index) {
|
||||||
return list.item(index);
|
return list.item(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int size() {
|
public int size() {
|
||||||
return list.getLength();
|
return list.getLength();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String nDigitFormat(BigDecimal value, int scale) {
|
public static String nDigitFormat(BigDecimal value, int scale) {
|
||||||
/*
|
/*
|
||||||
* I needed 123,45, locale independent.I tried
|
* I needed 123,45, locale independent.I tried
|
||||||
@@ -159,5 +167,21 @@ public class XMLTools extends XMLWriter {
|
|||||||
return zugferdData;
|
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
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user