package net.dongliu.apk.parser.bean;

/**
 * @author dongliu
 */
public class Locale {

    private String country;

    private String language;

    public static final Locale any = new Locale("", "");
    public static final Locale zh_CN = new Locale("CN", "zh");
    public static final Locale zh_TW = new Locale("TW", "zh");
    public static final Locale en_US = new Locale("US", "en");
    public static final Locale es_US = new Locale("US", "es");

    public Locale(String country, String language) {
        setCountry(country);
        setLanguage(language);
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        if (country == null || country.isEmpty() || country.charAt(0) == 0) {
            this.country = "";
        } else {
            this.country = country;
        }
    }

    public String getLanguage() {
        return language;
    }

    public void setLanguage(String language) {
        if (language == null || language.isEmpty() || language.charAt(0) == 0) {
            this.language = "";
        } else {
            this.language = language;
        }
    }

    public String toString() {
        return this.language + "_" + this.country;
    }

    public int match(Locale locale) {
        if (this.language.isEmpty() || this.language.equals(locale.language)) {
            if (this.language.isEmpty() || this.country.equals(locale.country)) {
                return 2;
            } else {
                return 1;
            }
        } else {
            return 0;
        }
    }
}

@@ -35,16 +35,127 @@
 n;%0A%0A/**%0A
+ * The java use ISO-639 and ISO-3166 to represent a local, with language lower case and country upper case.%0A *%0A
  * @auth
@@ -165,16 +165,16 @@
 dongliu%0A
-
  */%0Apubl
@@ -251,16 +251,53 @@
 guage;%0A%0A
+    // the most widely used locales%0A%0A
     publ
@@ -341,24 +341,87 @@
 le(%22%22, %22%22);%0A
+    public static final Locale en_US = new Locale(%22US%22, %22en%22);%0A
     public s
@@ -542,40 +542,157 @@
     
-public static final Locale en_US
+/**%0A     * Japanese%0A     */%0A    public static final Locale ja = new Locale(%22ja%22, %22%22);%0A    /**%0A     * German%0A     */%0A    public static final Locale de
  = n
@@ -706,56 +706,327 @@
 le(%22
-US
+ja
 %22, %22
-en%22);%0A    public static final Locale es_US
+%22);%0A    public static final Locale en = new Locale(%22en%22, %22%22);%0A    /**%0A     * Korean%0A     */%0A    public static final Locale ko = new Locale(%22ko%22, %22%22);%0A    /**%0A     * French%0A     */%0A    public static final Locale fr = new Locale(%22fr%22, %22%22);%0A    /**%0A     * Spanish; Castilian%0A     */%0A    public static final Locale es
  = n
@@ -1040,16 +1040,103 @@
 le(%22
-US
+es
 %22, %22
-es
+%22);%0A    /**%0A     * Russian%0A     */%0A    public static final Locale ru = new Locale(%22ru%22, %22
 %22);%0A
@@ -1985,35 +1985,8 @@
 if (
-this.language.isEmpty() %7C%7C 
 this
@@ -2043,24 +2043,23 @@
 f (this.
-language
+country
 .isEmpty

add more locale