diff --git a/src/main/java/se/injoin/gs1utils/ApplicationIdentifier.java b/src/main/java/se/injoin/gs1utils/ApplicationIdentifier.java index 2d13639..2cfe696 100644 --- a/src/main/java/se/injoin/gs1utils/ApplicationIdentifier.java +++ b/src/main/java/se/injoin/gs1utils/ApplicationIdentifier.java @@ -16,7 +16,7 @@ package se.injoin.gs1utils; /** - * Based on GS1 General Specifications, Release 17.0.1. + * Based on GS1 General Specifications, Release 19 *
* http://www.gs1.org/sites/default/files/docs/barcodes/GS1_General_Specifications.pdf
*/
@@ -98,6 +98,11 @@ public enum ApplicationIdentifier {
*/
SERIAL_NUMBER("21", Format.ALPHANUMERIC_VARIABLE, 20),
+ /**
+ * Consumer product variant [r.19]
+ */
+ CONSUMER_PRODUCT_VARIANT("22", Format.ALPHANUMERIC_VARIABLE, 20),
+
/**
* Additional product identification assigned by the manufacturer.
*/
@@ -162,6 +167,7 @@ public enum ApplicationIdentifier {
ITEM_AREA_SQUARE_METRES("314", Format.DECIMAL),
ITEM_NET_VOLUME_LITRES("315", Format.DECIMAL),
ITEM_NET_VOLUME_CUBIC_METRES("316", Format.DECIMAL),
+
ITEM_NET_WEIGHT_POUNDS("320", Format.DECIMAL),
ITEM_LENGTH_INCHES("321", Format.DECIMAL),
ITEM_LENGTH_FEET("322", Format.DECIMAL),
@@ -172,16 +178,6 @@ public enum ApplicationIdentifier {
ITEM_HEIGHT_INCHES("327", Format.DECIMAL),
ITEM_HEIGHT_FEET("328", Format.DECIMAL),
ITEM_HEIGHT_YARDS("329", Format.DECIMAL),
- ITEM_AREA_SQUARE_INCHES("350", Format.DECIMAL),
- ITEM_AREA_SQUARE_FEET("351", Format.DECIMAL),
- ITEM_AREA_SQUARE_YARDS("352", Format.DECIMAL),
- ITEM_NET_WEIGHT_TROY_OUNCES("356", Format.DECIMAL),
- ITEM_NET_VOLUME_OUNCES("357", Format.DECIMAL),
- ITEM_NET_VOLUME_QUARTS("360", Format.DECIMAL),
- ITEM_NET_VOLUME_GALLONS("361", Format.DECIMAL),
- ITEM_NET_VOLUME_CUBIC_INCHES("364", Format.DECIMAL),
- ITEM_NET_VOLUME_CUBIC_FEET("365", Format.DECIMAL),
- ITEM_NET_VOLUME_CUBIC_YARDS("366", Format.DECIMAL),
CONTAINER_GROSS_WEIGHT_KG("330", Format.DECIMAL),
CONTAINER_LENGTH_METRES("331", Format.DECIMAL),
@@ -190,6 +186,11 @@ public enum ApplicationIdentifier {
CONTAINER_AREA_SQUARE_METRES("334", Format.DECIMAL),
CONTAINER_VOLUME_LITRES("335", Format.DECIMAL),
CONTAINER_VOLUME_CUBIC_METRES("336", Format.DECIMAL),
+ /**
+ * Kilograms per square metre, of a particular trade item
+ */
+ KILOGRAMS_PER_SQUARE_METRE("337", Format.DECIMAL),
+
CONTAINER_GROSS_WEIGHT_POUNDS("340", Format.DECIMAL),
CONTAINER_LENGTH_INCHES("341", Format.DECIMAL),
CONTAINER_LENGTH_FEET("342", Format.DECIMAL),
@@ -200,20 +201,27 @@ public enum ApplicationIdentifier {
CONTAINER_HEIGHT_INCHES("347", Format.DECIMAL),
CONTAINER_HEIGHT_FEET("348", Format.DECIMAL),
CONTAINER_HEIGHT_YARDS("349", Format.DECIMAL),
+
+ ITEM_AREA_SQUARE_INCHES("350", Format.DECIMAL),
+ ITEM_AREA_SQUARE_FEET("351", Format.DECIMAL),
+ ITEM_AREA_SQUARE_YARDS("352", Format.DECIMAL),
CONTAINER_AREA_SQUARE_INCHES("353", Format.DECIMAL),
CONTAINER_AREA_SQUARE_FEET("354", Format.DECIMAL),
CONTAINER_AREA_SQUARE_YARDS("355", Format.DECIMAL),
+ ITEM_NET_WEIGHT_TROY_OUNCES("356", Format.DECIMAL),
+ ITEM_NET_VOLUME_OUNCES("357", Format.DECIMAL),
+
+ ITEM_NET_VOLUME_QUARTS("360", Format.DECIMAL),
+ ITEM_NET_VOLUME_GALLONS("361", Format.DECIMAL),
CONTAINER_VOLUME_QUARTS("362", Format.DECIMAL),
CONTAINER_VOLUME_GALLONS("363", Format.DECIMAL),
+ ITEM_NET_VOLUME_CUBIC_INCHES("364", Format.DECIMAL),
+ ITEM_NET_VOLUME_CUBIC_FEET("365", Format.DECIMAL),
+ ITEM_NET_VOLUME_CUBIC_YARDS("366", Format.DECIMAL),
CONTAINER_VOLUME_CUBIC_INCHES("367", Format.DECIMAL),
CONTAINER_VOLUME_CUBIC_FEET("368", Format.DECIMAL),
CONTAINER_VOLUME_CUBIC_YARDS("369", Format.DECIMAL),
- /**
- * Kilograms per square metre, of a particular trade item
- */
- KILOGRAMS_PER_SQUARE_METRE("337", Format.DECIMAL),
-
/**
* Count of trade items contained in a logistic unit.
*
@@ -427,7 +435,7 @@ public enum ApplicationIdentifier {
/**
* Revision status.
*/
- REVISION_STATUS("7021", Format.ALPHANUMERIC_VARIABLE, 20),
+ REVISION_STATUS("7022", Format.ALPHANUMERIC_VARIABLE, 20),
/**
* Global Individual Asset Identifier of an assembly.
@@ -478,6 +486,12 @@ public enum ApplicationIdentifier {
*/
PRODUCTION_DATE_AND_TIME("8008", Format.CUSTOM, 8, 12),
+ /**
+ * Optically Readable Sensor Indicator.
+ */
+ OPTICAL_READABLE_SENSOR_INDICATOR("8009", Format.ALPHANUMERIC_VARIABLE, 50),
+
+
/**
* Component / Part Identifier.
*/
@@ -492,6 +506,11 @@ public enum ApplicationIdentifier {
* Software version.
*/
SOFTWARE_VERSION("8012", Format.ALPHANUMERIC_VARIABLE, 20),
+
+ /**
+ * Global Model Number. [r.19]
+ */
+ GLOBAL_MODEL_NUMBER("8013", Format.ALPHANUMERIC_VARIABLE, 30),
/**
* Global Service Relation Number of provider.
@@ -515,6 +534,11 @@ public enum ApplicationIdentifier {
*/
PAYMENT_SLIP_REFERENCE_NUMBER("8020", Format.ALPHANUMERIC_VARIABLE, 25),
+ /**
+ * Identification of pieces of a trade item contained in a logistic unit [r.19]
+ */
+ ITIP_CONTAINED_IN_A_LOGISTIC_UNIT("8026", Format.NUMERIC_FIXED, 18),
+
/**
* Coupon code identification for use in North America.
*/
@@ -540,9 +564,17 @@ public enum ApplicationIdentifier {
/**
* Information mutually agreed between trading partners.
*/
- MUTUALLY_AGREED_INFORMATION("90", Format.ALPHANUMERIC_VARIABLE, 30);
-
- // No constants defined for 91-99 Company internal information. Query parse result using strings.
+ MUTUALLY_AGREED_INFORMATION("90", Format.ALPHANUMERIC_VARIABLE, 30),
+
+ COMPANY_INTERNAL_INFORMATION_1("91", Format.ALPHANUMERIC_VARIABLE, 90),
+ COMPANY_INTERNAL_INFORMATION_2("92", Format.ALPHANUMERIC_VARIABLE, 90),
+ COMPANY_INTERNAL_INFORMATION_3("93", Format.ALPHANUMERIC_VARIABLE, 90),
+ COMPANY_INTERNAL_INFORMATION_4("94", Format.ALPHANUMERIC_VARIABLE, 90),
+ COMPANY_INTERNAL_INFORMATION_5("95", Format.ALPHANUMERIC_VARIABLE, 90),
+ COMPANY_INTERNAL_INFORMATION_6("96", Format.ALPHANUMERIC_VARIABLE, 90),
+ COMPANY_INTERNAL_INFORMATION_7("97", Format.ALPHANUMERIC_VARIABLE, 90),
+ COMPANY_INTERNAL_INFORMATION_8("98", Format.ALPHANUMERIC_VARIABLE, 90),
+ COMPANY_INTERNAL_INFORMATION_9("99", Format.ALPHANUMERIC_VARIABLE, 90);
private final String key;
private final Format format;
diff --git a/src/main/java/se/injoin/gs1utils/ApplicationIdentifierTree.java b/src/main/java/se/injoin/gs1utils/ApplicationIdentifierTree.java
new file mode 100644
index 0000000..77c6c7f
--- /dev/null
+++ b/src/main/java/se/injoin/gs1utils/ApplicationIdentifierTree.java
@@ -0,0 +1,79 @@
+package se.injoin.gs1utils;
+
+class ApplicationIdentifierTree {
+ static ApplicationIdentifierTree instance = buildTree();
+
+ static ApplicationIdentifier get(String key) {
+ ApplicationIdentifierTree tree = instance;
+ for (int i = 0; i < key.length(); i++) {
+ char ch = key.charAt(i);
+ if (ch < '0' || ch > '9')
+ return null;
+ IdentifierOrTree node = tree.map[(int)(ch - '0')];
+ if (null == node)
+ return null;
+ if (node.isTree()) {
+ tree = node.getTree();
+ } else {
+ return node.getIdentifier();
+ }
+ }
+ return null;
+ }
+
+ static class IdentifierOrTree {
+ ApplicationIdentifier identifier = null;
+ ApplicationIdentifierTree tree = null;
+
+ IdentifierOrTree(ApplicationIdentifier identifier) {
+ this.identifier = identifier;
+ }
+ IdentifierOrTree(ApplicationIdentifierTree tree) {
+ this.tree = tree;
+ }
+
+ boolean isTree() {
+ return null != this.tree;
+ }
+
+ ApplicationIdentifierTree getTree() {
+ return this.tree;
+ }
+
+ ApplicationIdentifier getIdentifier() {
+ return this.identifier;
+ }
+ }
+
+ IdentifierOrTree[] map = new IdentifierOrTree[] {
+ null, null, null, null, null,
+ null, null, null, null, null
+ };
+
+ ApplicationIdentifierTree() {
+ }
+
+ void addLeaf(char[] key, int pos, ApplicationIdentifier identifier) {
+ char ch = key[pos];
+ if (ch < '0' || ch > '9')
+ return;
+ int mapKey = (int)(ch - '0');
+ if (pos == (key.length - 1)) {
+ this.map[mapKey] = new IdentifierOrTree(identifier);
+ } else {
+ if (null == this.map[mapKey]) {
+ this.map[mapKey] = new IdentifierOrTree(new ApplicationIdentifierTree());
+ }
+ this.map[mapKey].getTree().addLeaf(key, pos+1, identifier);
+ }
+ }
+
+ static ApplicationIdentifierTree buildTree() {
+ ApplicationIdentifierTree tree = new ApplicationIdentifierTree();
+ for (ApplicationIdentifier item : ApplicationIdentifier.values()) {
+ tree.addLeaf(item.getKey().toCharArray(), 0, item);
+ }
+ return tree;
+ }
+
+}
diff --git a/src/main/java/se/injoin/gs1utils/ElementStrings.java b/src/main/java/se/injoin/gs1utils/ElementStrings.java
index a0aaf17..e043a9a 100644
--- a/src/main/java/se/injoin/gs1utils/ElementStrings.java
+++ b/src/main/java/se/injoin/gs1utils/ElementStrings.java
@@ -63,12 +63,12 @@ public BigDecimal getDecimal(String key) {
return (BigDecimal) elementsByString.get(key);
}
- public List getList(ApplicationIdentifier identifier) {
- return (List) elementsByEnum.get(identifier);
+ public List> getList(ApplicationIdentifier identifier) {
+ return (List>) elementsByEnum.get(identifier);
}
- public List getList(String key) {
- return (List) elementsByString.get(key);
+ public List> getList(String key) {
+ return (List>) elementsByString.get(key);
}
public Object getObject(String key) {
@@ -98,6 +98,11 @@ public Map