diff --git a/epc-core/src/main/java/com/nike/epc/model/xndt/Xndt.java b/epc-core/src/main/java/com/nike/epc/model/xndt/Xndt.java index 2cc2bf4..fbdecbf 100644 --- a/epc-core/src/main/java/com/nike/epc/model/xndt/Xndt.java +++ b/epc-core/src/main/java/com/nike/epc/model/xndt/Xndt.java @@ -67,6 +67,13 @@ public static Xndt fromBits(RawBits bits, int size) { // [12, 54) - 42 bits String style = bits.getBase64Decoded(12, 42); + // This is an ugly hack to deal with styles with leading As that + // are 6 digits. No style will be less than 6 digits. If a style + // is 7 digits and starts with A it will still be broken. Encoding + // of these will need to be modified to fully resolve this issue. + while (style.length() < 6) { + style = 'A' + style; + } // [54, 72) - 18 bits String color = bits.getBase64Decoded(54, 18); diff --git a/epc-core/src/test/java/com/nike/epc/model/xndt/XndtTest.java b/epc-core/src/test/java/com/nike/epc/model/xndt/XndtTest.java index bf08c91..7e17f62 100644 --- a/epc-core/src/test/java/com/nike/epc/model/xndt/XndtTest.java +++ b/epc-core/src/test/java/com/nike/epc/model/xndt/XndtTest.java @@ -30,4 +30,15 @@ public void parseXndt() { assertEquals("Z9Z9Z9-ZZZ", xndt.styleColor()); assertEquals(10, xndt.serialNumber()); } + + @Test + public void praseWithoutDroppingLeadingA() { + // Q4312-600 + RawBits bits = RawBits.fromHex("E31000438DF5DBAD3400001E"); + Xndt xndt = Xndt.fromBits(bits, 96); + + assertEquals("AQ4312", xndt.style()); + assertEquals("600", xndt.color()); + assertEquals("AQ4312-600", xndt.styleColor()); + } }