coparing arrays for beginners
This commit is contained in:
@@ -23,12 +23,7 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.StandardOpenOption;
|
import java.nio.file.StandardOpenOption;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Scanner;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -117,7 +112,7 @@ public class ZUGFeRDImporter {
|
|||||||
pdfStream.read(pad);
|
pdfStream.read(pad);
|
||||||
pdfStream.reset();
|
pdfStream.reset();
|
||||||
byte[] pdfSignature = {'%', 'P', 'D', 'F'};
|
byte[] pdfSignature = {'%', 'P', 'D', 'F'};
|
||||||
if (pad.equals(pdfSignature)) { // we have a pdf
|
if (Arrays.equals(pad, pdfSignature)) { // we have a pdf
|
||||||
|
|
||||||
|
|
||||||
try (PDDocument doc = PDDocument.load(pdfStream)) {
|
try (PDDocument doc = PDDocument.load(pdfStream)) {
|
||||||
@@ -221,8 +216,6 @@ public class ZUGFeRDImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected String extractString(String xpathStr) {
|
protected String extractString(String xpathStr) {
|
||||||
if (!containsMeta) {
|
if (!containsMeta) {
|
||||||
throw new ZUGFeRDExportException("No suitable data/ZUGFeRD file could be found.");
|
throw new ZUGFeRDExportException("No suitable data/ZUGFeRD file could be found.");
|
||||||
@@ -365,6 +358,7 @@ public class ZUGFeRDImporter {
|
|||||||
"//*[local-name() = 'StartDateTime']//*[local-name() = 'DateTimeString']");
|
"//*[local-name() = 'StartDateTime']//*[local-name() = 'DateTimeString']");
|
||||||
return tryDate(toParse);
|
return tryDate(toParse);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getDetailedDeliveryPeriodTo() {
|
public Date getDetailedDeliveryPeriodTo() {
|
||||||
final String toParse = extractString(
|
final String toParse = extractString(
|
||||||
"//*[local-name() = 'ApplicableHeaderTradeSettlement']" +
|
"//*[local-name() = 'ApplicableHeaderTradeSettlement']" +
|
||||||
@@ -480,7 +474,9 @@ public class ZUGFeRDImporter {
|
|||||||
*/
|
*/
|
||||||
public String getBuyerTradePartyName() {
|
public String getBuyerTradePartyName() {
|
||||||
return extractString("//*[local-name() = 'BuyerTradeParty']//*[local-name() = 'Name']");
|
return extractString("//*[local-name() = 'BuyerTradeParty']//*[local-name() = 'Name']");
|
||||||
} /**
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* @return the BuyerTradeParty Name
|
* @return the BuyerTradeParty Name
|
||||||
*/
|
*/
|
||||||
public String getDeliveryTradePartyName() {
|
public String getDeliveryTradePartyName() {
|
||||||
@@ -488,7 +484,6 @@ public class ZUGFeRDImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the line Total Amount
|
* @return the line Total Amount
|
||||||
*/
|
*/
|
||||||
@@ -545,7 +540,6 @@ public class ZUGFeRDImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the document code
|
* @return the document code
|
||||||
*/
|
*/
|
||||||
@@ -697,6 +691,7 @@ public class ZUGFeRDImporter {
|
|||||||
throw new Exception("ZUGFeRD version could not be determined");
|
throw new Exception("ZUGFeRD version could not be determined");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVersion() throws Exception {
|
public int getVersion() throws Exception {
|
||||||
if (!containsMeta) {
|
if (!containsMeta) {
|
||||||
throw new Exception("Not yet parsed");
|
throw new Exception("Not yet parsed");
|
||||||
@@ -713,8 +708,7 @@ public class ZUGFeRDImporter {
|
|||||||
version = 1;
|
version = 1;
|
||||||
} else if (head.contains("<rsm:CrossIndustryInvoice")) {
|
} else if (head.contains("<rsm:CrossIndustryInvoice")) {
|
||||||
version = 2;
|
version = 2;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
throw new Exception("ZUGFeRD version could not be determined");
|
throw new Exception("ZUGFeRD version could not be determined");
|
||||||
}
|
}
|
||||||
return version;
|
return version;
|
||||||
@@ -784,6 +778,7 @@ public class ZUGFeRDImporter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* returns an instance of PostalTradeAddress for SellerTradeParty section
|
* returns an instance of PostalTradeAddress for SellerTradeParty section
|
||||||
|
*
|
||||||
* @return an instance of PostalTradeAddress
|
* @return an instance of PostalTradeAddress
|
||||||
*/
|
*/
|
||||||
public PostalTradeAddress getBuyerTradePartyAddress() {
|
public PostalTradeAddress getBuyerTradePartyAddress() {
|
||||||
@@ -806,6 +801,7 @@ public class ZUGFeRDImporter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* returns an instance of PostalTradeAddress for SellerTradeParty section
|
* returns an instance of PostalTradeAddress for SellerTradeParty section
|
||||||
|
*
|
||||||
* @return an instance of PostalTradeAddress
|
* @return an instance of PostalTradeAddress
|
||||||
*/
|
*/
|
||||||
public PostalTradeAddress getSellerTradePartyAddress() {
|
public PostalTradeAddress getSellerTradePartyAddress() {
|
||||||
@@ -827,6 +823,7 @@ public class ZUGFeRDImporter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* returns an instance of PostalTradeAddress for ShipToTradeParty section
|
* returns an instance of PostalTradeAddress for ShipToTradeParty section
|
||||||
|
*
|
||||||
* @return an instance of PostalTradeAddress
|
* @return an instance of PostalTradeAddress
|
||||||
*/
|
*/
|
||||||
public PostalTradeAddress getDeliveryTradePartyAddress() {
|
public PostalTradeAddress getDeliveryTradePartyAddress() {
|
||||||
@@ -910,6 +907,7 @@ public class ZUGFeRDImporter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* returns a list of LineItems
|
* returns a list of LineItems
|
||||||
|
*
|
||||||
* @return a List of LineItem instances
|
* @return a List of LineItem instances
|
||||||
*/
|
*/
|
||||||
public List<Item> getLineItemList() {
|
public List<Item> getLineItemList() {
|
||||||
@@ -1041,6 +1039,7 @@ public class ZUGFeRDImporter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* returns a List of LineItem Nodes from ZUGFeRD XML
|
* returns a List of LineItem Nodes from ZUGFeRD XML
|
||||||
|
*
|
||||||
* @return a List of Node instances
|
* @return a List of Node instances
|
||||||
*/
|
*/
|
||||||
public List<Node> getLineItemNodes() {
|
public List<Node> getLineItemNodes() {
|
||||||
@@ -1062,6 +1061,7 @@ public class ZUGFeRDImporter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a node, found by name. If more nodes with the same name are present, the first occurence will be returned
|
* Returns a node, found by name. If more nodes with the same name are present, the first occurence will be returned
|
||||||
|
*
|
||||||
* @param nl - A NodeList which may contains the searched node
|
* @param nl - A NodeList which may contains the searched node
|
||||||
* @param name The nodes name
|
* @param name The nodes name
|
||||||
* @return a Node or null, if nothing is found
|
* @return a Node or null, if nothing is found
|
||||||
@@ -1082,6 +1082,7 @@ public class ZUGFeRDImporter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a NodeList by providing an path
|
* Get a NodeList by providing an path
|
||||||
|
*
|
||||||
* @param path a compliable Path
|
* @param path a compliable Path
|
||||||
* @return a Nodelist or null, if an error occurs
|
* @return a Nodelist or null, if an error occurs
|
||||||
*/
|
*/
|
||||||
@@ -1102,6 +1103,7 @@ public class ZUGFeRDImporter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the value of an node
|
* returns the value of an node
|
||||||
|
*
|
||||||
* @param node the Node to get the value from
|
* @param node the Node to get the value from
|
||||||
* @return A String or empty String, if no value was found
|
* @return A String or empty String, if no value was found
|
||||||
*/
|
*/
|
||||||
@@ -1114,6 +1116,7 @@ public class ZUGFeRDImporter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* tries to convert an String to BigDecimal.
|
* tries to convert an String to BigDecimal.
|
||||||
|
*
|
||||||
* @param nodeValue The value as String
|
* @param nodeValue The value as String
|
||||||
* @return a BigDecimal with the value provides as String or a BigDecimal with value 0.00 if an error occurs
|
* @return a BigDecimal with the value provides as String or a BigDecimal with value 0.00 if an error occurs
|
||||||
*/
|
*/
|
||||||
@@ -1128,6 +1131,7 @@ public class ZUGFeRDImporter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Date tryDate(Node node) {
|
private Date tryDate(Node node) {
|
||||||
final String nodeValue = getNodeValue(node);
|
final String nodeValue = getNodeValue(node);
|
||||||
if (nodeValue.isEmpty()) {
|
if (nodeValue.isEmpty()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user