@@ -0,0 +1,2126 @@
+/*%0A * %5BNayati%5D TrackNum.java%0A *%0A * Defines a model class representing a tracking number.%0A *%0A * (c) 2015 Sanjeev Premi (spremi@ymail.com)%0A *%0A * SPDX-License-Identifier: BSD-3-Clause%0A *                          (http://spdx.org/licenses/BSD-3-Clause.html)%0A *%0A */%0A%0A%0Apackage self.premi.sanjeev.nayati.model;%0A%0A%0A/**%0A * Defines tracking number%0A */%0Apublic class TrackNum %7B%0A%0A    /**%0A     * Unknown format%0A     */%0A    public static final int F_NONE = -1;%0A%0A    /**%0A     * EMS (Domestic & International)%0A     */%0A    public static final int F_EMS = 1;%0A%0A    /**%0A     * Registered mail%0A     */%0A    public static final int F_REG = 2;%0A%0A    /**%0A     * Express parcel post%0A     */%0A    public static final int F_EPP = 3;%0A%0A    /**%0A     * Electronic Money Order%0A     */%0A    public static final int F_EMO = 4;%0A%0A    /**%0A     * Regular expression - EMS%0A     */%0A    private final String regexEMS = %22(EE)(%5B0-9%5D%7B9%7D)(%5BA-Z%5D%7B2%7D)%22;%0A%0A    /**%0A     * Regular expression - Registered Post%0A     */%0A    private final String regexREG = %22(R%5BA-Z%5D)(%5B0-9%5D%7B9%7D)(%5BA-Z%5D%7B2%7D)%22;%0A%0A    /**%0A     * Regular expression - Express Parcel%0A     */%0A    private final String regexEPP = %22(%5BA-Z%5D%7B2%7D)(%5B0-9%5D%7B9%7D)(%5BA-Z%5D%7B2%7D)%22;%0A%0A    /**%0A     * Regular expression - Electronic Money Order%0A     */%0A    private final String regexEMO = %22(%5B0-9%5D%7B18%7D)%22;%0A%0A%0A    /**%0A     * Tracking number%0A     */%0A    private String track;%0A%0A%0A    /**%0A     * Constructor%0A     */%0A    public TrackNum(String track) %7B%0A        this.track = track;%0A    %7D%0A%0A%0A    /**%0A     * Identify format of the tracking number%0A     */%0A    public int identify() %7B%0A        int len = track.length();%0A%0A        //%0A        // Insufficient characters for a 'trackable' post%0A        //%0A        if (len %3C 13) return F_NONE;%0A%0A        //%0A        // Insufficient characters for en eMO%0A        //%0A        if ((len %3E 13) && (len != 18)) return F_NONE;%0A%0A        if (len == 13) %7B%0A            if (track.matches(regexEMS)) return F_EMS;%0A%0A            if (track.matches(regexREG)) return F_REG;%0A%0A            if (track.matches(regexEPP)) return F_EPP;%0A        %7D else %7B%0A            if (track.matches(regexEMO)) return F_EMO;%0A        %7D%0A%0A        return F_NONE;%0A    %7D%0A%7D%0A

Define class 'TrackNum'