File tree Expand file tree Collapse file tree 2 files changed +23
-6
lines changed
core/src/main/java/io/snabble/sdk/codes Expand file tree Collapse file tree 2 files changed +23
-6
lines changed Original file line number Diff line number Diff line change 1+ package io .snabble .sdk .codes ;
2+
3+ public class EAN14 extends ScannableCode {
4+ public EAN14 (String code ) {
5+ super (code );
6+
7+ if (code .length () == 16 ) {
8+ this .code = code .substring (2 , code .length ());
9+ }
10+ }
11+
12+ public static boolean isEan14 (String code ) {
13+ return code != null && (code .length () == 16 && code .startsWith ("01" ) || code .length () == 14 );
14+ }
15+ }
Original file line number Diff line number Diff line change 55import io .snabble .sdk .SnabbleSdk ;
66
77public class ScannableCode implements Serializable {
8- private String code ;
8+ protected String code ;
99
10- public ScannableCode (String code ){
10+ public ScannableCode (String code ) {
1111 this .code = code ;
1212 }
1313
14- public String getCode (){
14+ public String getCode () {
1515 return code ;
1616 }
1717
@@ -35,17 +35,19 @@ public boolean hasWeighData() {
3535 return false ;
3636 }
3737
38- public boolean hasEmbeddedData (){
38+ public boolean hasEmbeddedData () {
3939 return false ;
4040 }
4141
4242 public boolean isEmbeddedDataOk () {
4343 return true ;
4444 }
4545
46- public static ScannableCode parse (SnabbleSdk snabbleSdk , String code ){
47- if (EAN13 .isEan13 (code )){
46+ public static ScannableCode parse (SnabbleSdk snabbleSdk , String code ) {
47+ if (EAN13 .isEan13 (code )) {
4848 return new EAN13 (code , snabbleSdk );
49+ } else if (EAN14 .isEan14 (code )) {
50+ return new EAN14 (code );
4951 } else {
5052 return new ScannableCode (code );
5153 }
You can’t perform that action at this time.
0 commit comments