I need a review on this.  This code will read a 2D matrix bar code, which I hard-coded as a string str.  It has ]d starting string, which is a GS1 International body Bar Code spec. after that.  It has information about Item Number, Serial Number, Locator Information.  This code will read the entire string, split and validate fields as per US, SK or Ireland country specs.public class App {    public static int pos;    public static String getLotNo;    public static String getExpDt;    public static String getItemNo;    public static String getTrimItemNo(String itemNo) {        return itemNo.trim();    }    public static String getItemNumber(String str) {        String matchItemAI = 01;        pos = str.indexOf(matchItemAI);        // Company Prefix for US        if (str.substring(5, 7).equals(03)) {            System.out.println(US Company Prefix :);            String itemStr = str.substring(pos + 5, str.length());            System.out.println(itemStr);            String itemNo = String.format(%s-%s-%s, itemStr.substring(0, 5),                    itemStr.substring(5, 9), itemStr.substring(9, 10));            return itemNo = itemNo.trim();        }// For Ireland        else if (str.substring(5, 7).equals(53)) {            System.out.println(Cork Company Prefix :);// 539150714            System.out.println(Cork Company Prefix ----POS: + pos);            System.out.println(Cork Company Prefix ----STR: + str);            String itemStr = str.substring(pos + 8, str.length());            System.out.println(Cork Company Prefix ----: + itemStr);            String itemNo = String.format(%s-%s-%s, itemStr.substring(0, 5),                    itemStr.substring(5, 9), itemStr.substring(9, 10));            return itemNo = itemNo.trim();        }// For South Korea        else if (str.substring(5, 7).equals(88)) {            System.out.println(South Korea Company Prefix :);            String itemStr = str.substring(pos + 8, str.length());            System.out.println(itemStr);            String itemNo = String.format(%s-%s-%s, itemStr.substring(0, 5),                    itemStr.substring(5, 9), itemStr.substring(9, 10));            return itemNo = itemNo.trim();        } else {            System.out.println(Not Found Company Prefix);            return null;        }    }    public static String getSNo(String str) {        String matchSNoAI = 21; // AI Serial Number 21        pos = str.indexOf(matchSNoAI);        String matchExpDtAI = ]d17;// ExpiryDate Group Seprator        String getSNo = str.substring(pos + 2, str.lastIndexOf(matchExpDtAI));        return getSNo = getSNo.trim();    }    public static String getExpDt(String str, String matchExpDtAI) {            pos = str.lastIndexOf(matchExpDtAI);            getExpDt = str.substring(pos + 4, pos + 4 + 6);            return getExpDt = getExpDt.trim();        }        public static String getLotNo(String str) {            String matchLotNoAI = 10; // AI Lot Number            pos = str.lastIndexOf(matchLotNoAI);            getLotNo = str.substring(pos + 2, pos + 2 + 11);            return getLotNo = getLotNo.trim();        }        public static void main(String[] arg) {            // US GS1 String            // 01 AI    // 0 Packing Indicator    // 03 GS1 US Code    // 61958 FDA Code    // 07011 Assigned Product Code    // 1 Asigned Packinging Code    // 9 Check Digit Code               String str = new String(             ]d010036195815011121123456789]d17YYMMDD1012345678901);            // South Korea String            // String str = new String(            // ]d010880625915011821123456789]d17YYMMDD1012345678901);            // Ireland String            // String str = new String(            //      ]d010539150714011821123456789]d17YYMMDD1012345678901);            String withoutFunctionKey = str;            if (str.startsWith(]d)) {                System.out.println(GS1 2D Input String : + str);                switch (str.charAt(2)) { // Scan UNIT 0                case '0':                    // Get Item Number                    withoutFunctionKey = getItemNumber(str);                    System.out.println(Found Item Number :                                + withoutFunctionKey);                    // Get Serial Number                    String matchExpDtAI = ]d17;// ExpiryDate                    withoutFunctionKey = getSNo(str);                    System.out.println(Found string Serial Number :                                + withoutFunctionKey);                    // Get Expiry Date                    withoutFunctionKey = getExpDt(str, matchExpDtAI);                    System.out.println(Found string Expiry Date :                               + withoutFunctionKey);                    // Get Lot Number                    withoutFunctionKey = getLotNo(str);                    System.out.println(Found string Lot Number  :                             + withoutFunctionKey);                    break;                case '3':                    // BUNDLE 3                    System.out                            .println(Bundle/Multipack 3 Packaging Indicator digits for GTIN 14's  :                                     + str.charAt(2));                    break;                // SHIPPER 5                case '5':                    System.out                            .println(Shipper 5 Packaging Indicator digits for GTIN 14's  :                                     + str.charAt(2));                    break;                default:                    System.out                            .println(Error - invalid selection entered! for Multipacking );                    break;                }            }        }    }
Reading and validating 2D matrix bar code
java;strings;parsing;validation