Skip to content

Commit

Permalink
SGTIN-96 and SGTIN-198 implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
jlcout committed Nov 3, 2017
1 parent b662dfe commit 462fd21
Show file tree
Hide file tree
Showing 6 changed files with 659 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.epctagcoder.option.SGTIN;

import java.util.LinkedHashMap;
import java.util.Map;

public enum SGTINExtensionDigit {
EXTENSION_0(0),
EXTENSION_1(1),
EXTENSION_2(2),
EXTENSION_3(3),
EXTENSION_4(4),
EXTENSION_5(5),
EXTENSION_6(6),
EXTENSION_7(7),
EXTENSION_8(8),
EXTENSION_9(9);

private int value;

private SGTINExtensionDigit(int value) {
this.value = value;
}

public int getValue() {
return value;
}

private static final Map<Integer, SGTINExtensionDigit> BY_CODE_MAP = new LinkedHashMap<>();
static {
for (SGTINExtensionDigit rae : SGTINExtensionDigit.values()) {
BY_CODE_MAP.put(rae.value, rae);
}
}

public static SGTINExtensionDigit forCode(int code) {
return BY_CODE_MAP.get(code);
}




}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.epctagcoder.option.SGTIN;

import java.util.LinkedHashMap;
import java.util.Map;

public enum SGTINFilterValue {
ALL_OTHERS_0(0),
POS_ITEM_1(1),
CASE_2(2),
RESERVED_3(3),
INNER_PACK_4(4),
RESERVED_5(5),
UNIT_LOAD_6(6),
COMPONENT_7(7);

private int value;

private SGTINFilterValue(int value) {
this.value = value;
}

public int getValue() {
return value;
}

private static final Map<Integer, SGTINFilterValue> BY_CODE_MAP = new LinkedHashMap<>();
static {
for (SGTINFilterValue rae : SGTINFilterValue.values()) {
BY_CODE_MAP.put(rae.value, rae);
}
}

public static SGTINFilterValue forCode(int code) {
return BY_CODE_MAP.get(code);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.epctagcoder.option.SGTIN;

import java.util.LinkedHashMap;
import java.util.Map;

public enum SGTINHeader {
HEADER_00110000("00110000") {
public Integer getTagSize() {
return 96;
}
},
HEADER_00110110("00110110") {
public Integer getTagSize() {
return 198;
}
};

private String value;
public abstract Integer getTagSize();


private SGTINHeader(String value) {
this.value = value;
}

public String getValue() {
return value;
}

private static final Map<String, SGTINHeader> BY_CODE_MAP = new LinkedHashMap<>();
static {
for (SGTINHeader rae : SGTINHeader.values()) {
BY_CODE_MAP.put(rae.value, rae);
}
}

public static SGTINHeader forCode(String code) {
return BY_CODE_MAP.get(code);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package org.epctagcoder.option.SGTIN;

import java.util.LinkedHashMap;
import java.util.Map;

public enum SGTINTagSize {
BITS_96(96) {
public Integer getHeader() {
return 48;
}
public Integer getSerialBitCount() {
return 38;
}
public Integer getSerialMaxLenght() {
return 11;
}
public Long getSerialMaxValue() {
return 274_877_906_943L;
}
},
BITS_198(198) {
public Integer getHeader() {
return 54;
}
public Integer getSerialBitCount() {
return 140;
}
public Integer getSerialMaxLenght() {
return 20;
}
public Long getSerialMaxValue() {
return null; // not used
}
};

private int value;
public abstract Integer getHeader();
public abstract Integer getSerialBitCount();
public abstract Integer getSerialMaxLenght();
public abstract Long getSerialMaxValue();

private SGTINTagSize(int value) {
this.value = value;
}

public int getValue() {
return value;
}

private static final Map<Integer, SGTINTagSize> BY_CODE_MAP = new LinkedHashMap<>();
static {
for (SGTINTagSize rae : SGTINTagSize.values()) {
BY_CODE_MAP.put(rae.value, rae);
}
}

public static SGTINTagSize forCode(int code) {
return BY_CODE_MAP.get(code);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.epctagcoder.option.SGTIN.partitionTable;

import java.util.ArrayList;
import java.util.List;

import org.epctagcoder.option.TableItem;


public class SGTINPartitionTableList {
static final private List<TableItem> list = new ArrayList<TableItem>();

static {
list.add( new TableItem(0, 40, 12, 4, 1) );
list.add( new TableItem(1, 37, 11, 7, 2) );
list.add( new TableItem(2, 34, 10, 10, 3) );
list.add( new TableItem(3, 30, 9, 14, 4) );
list.add( new TableItem(4, 27, 8, 17, 5) );
list.add( new TableItem(5, 24, 7, 20, 6) );
list.add( new TableItem(6, 20, 6, 24, 7) );
}

public SGTINPartitionTableList() {

}


public TableItem getPartitionByL(Integer index) {
TableItem tableItem = null;
for (TableItem item : list) {
if (item.getL()==index) {
tableItem = item;
break;
}
}
return tableItem;
}

public TableItem getPartitionByValue(Integer index) {
TableItem tableItem = null;
for (TableItem item : list) {
if (item.getPartitionValue()==index) {
tableItem = item;
break;
}
}
return tableItem;
}


}
Loading

0 comments on commit 462fd21

Please sign in to comment.