All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.launchdarkly.client.LDCountryCode Maven / Gradle / Ivy

/*
 * Copyright (C) 2012-2014 Neo Visionaries Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Taken verbatim from https://github.com/TakahikoKawasaki/nv-i18n and moved to
 * the com.launchdarkly.client package to avoid class loading issues.
 */
package com.launchdarkly.client;


import java.util.ArrayList;
import java.util.Currency;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Pattern;


/**
 * ISO 3166-1 country code.
 *
 * 

* Enum names of this enum themselves are represented by * ISO 3166-1 alpha-2 * code (2-letter upper-case alphabets). There are instance methods to get the * country name ({@link #getName()}), the * ISO 3166-1 alpha-3 * code ({@link #getAlpha3()}) and the * ISO 3166-1 numeric * code ({@link #getNumeric()}). * In addition, there are static methods to get a {@code CountryCode} instance that * corresponds to a given alpha-2/alpha-3/numeric code ({@link #getByCode(String)}, * {@link #getByCode(int)}). *

* *
 * // List all the country codes.
 * for (CountryCode code : CountryCode.values())
 * {
 *     // For example, "[US] United States" is printed.
 *     System.out.format("[%s] %s\n", code, code.{@link #getName()});
 * }
 *
 * // Get a CountryCode instance by ISO 3166-1 code.
 * CountryCode code = CountryCode.{@link #getByCode(String) getByCode}("JP");
 *
 * // Print all the information. Output will be:
 * //
 * //     Country name            = Japan
 * //     ISO 3166-1 alpha-2 code = JP
 * //     ISO 3166-1 alpha-3 code = JPN
 * //     ISO 3166-1 numeric code = 392
 * //     Assignment state        = OFFICIALLY_ASSIGNED
 * //
 * System.out.println("Country name            = " + code.{@link #getName()});
 * System.out.println("ISO 3166-1 alpha-2 code = " + code.{@link #getAlpha2()});
 * System.out.println("ISO 3166-1 alpha-3 code = " + code.{@link #getAlpha3()});
 * System.out.println("ISO 3166-1 numeric code = " + code.{@link #getNumeric()});
 * System.out.println("Assignment state        = " + code.{@link #getAssignment()});
 *
 * // Convert to a Locale instance.
 * {@link Locale} locale = code.{@link #toLocale()};
 *
 * // Get a CountryCode by a Locale instance.
 * code = CountryCode.{@link #getByLocale(Locale) getByLocale}(locale);
 *
 * // Get the currency of the country.
 * {@link Currency} currency = code.{@link #getCurrency()};
 *
 * // Get a list by a regular expression for names.
 * //
 * // The list will contain:
 * //
 * //     CountryCode.AE : United Arab Emirates
 * //     CountryCode.GB : United Kingdom
 * //     CountryCode.TZ : Tanzania, United Republic of
 * //     CountryCode.UK : United Kingdom
 * //     CountryCode.UM : United States Minor Outlying Islands
 * //     CountryCode.US : United States
 * //
 * List<CountryCode> list = CountryCode.{@link #findByName(String) findByName}(".*United.*");
 * 
* * @author Takahiko Kawasaki */ public enum LDCountryCode { /** * Ascension Island * [AC, ASC, -1, * Exceptionally reserved] */ AC("Ascension Island", "ASC", -1, Assignment.EXCEPTIONALLY_RESERVED), /** * Andorra * [AD, AND, 16, * Officially assigned] */ AD("Andorra", "AND", 20, Assignment.OFFICIALLY_ASSIGNED), /** * United Arab Emirates * [AE, AE, 784, * Officially assigned] */ AE("United Arab Emirates", "ARE", 784, Assignment.OFFICIALLY_ASSIGNED), /** * Afghanistan * [AF, AFG, 4, * Officially assigned] */ AF("Afghanistan", "AFG", 4, Assignment.OFFICIALLY_ASSIGNED), /** * Antigua and Barbuda * [AG, ATG, 28, * Officially assigned] */ AG("Antigua and Barbuda", "ATG", 28, Assignment.OFFICIALLY_ASSIGNED), /** * Anguilla * [AI, AIA, 660, * Officially assigned] */ AI("Anguilla", "AIA", 660, Assignment.OFFICIALLY_ASSIGNED), /** * Albania * [AL, ALB, 8, * Officially assigned] */ AL("Albania", "ALB", 8, Assignment.OFFICIALLY_ASSIGNED), /** * Armenia * [AM, ARM, 51, * Officially assigned] */ AM("Armenia", "ARM", 51, Assignment.OFFICIALLY_ASSIGNED), /** * Netherlands Antilles * [AN, ANHH, 530, * Traditionally reserved] */ AN("Netherlands Antilles", "ANHH", 530, Assignment.TRANSITIONALLY_RESERVED), /** * Angola * [AO, AGO, 24, * Officially assigned] */ AO("Angola", "AGO", 24, Assignment.OFFICIALLY_ASSIGNED), /** * Antarctica * [AQ, ATA, 10, * Officially assigned] */ AQ("Antarctica", "ATA", 10, Assignment.OFFICIALLY_ASSIGNED), /** * Argentina * [AR, ARG, 32, * Officially assigned] */ AR("Argentina", "ARG", 32, Assignment.OFFICIALLY_ASSIGNED), /** * American Samoa * [AS, ASM, 16, * Officially assigned] */ AS("American Samoa", "ASM", 16, Assignment.OFFICIALLY_ASSIGNED), /** * Austria * [AT, AUT, 40, * Officially assigned] */ AT("Austria", "AUT", 40, Assignment.OFFICIALLY_ASSIGNED), /** * Australia * [AU, AUS, 36, * Officially assigned] */ AU("Australia", "AUS", 36, Assignment.OFFICIALLY_ASSIGNED), /** * Aruba * [AW, ABW, 533, * Officially assigned] */ AW("Aruba", "ABW", 533, Assignment.OFFICIALLY_ASSIGNED), /** * Åland Islands * [AX, ALA, 248, * Officially assigned] */ AX("\u212Bland Islands", "ALA", 248, Assignment.OFFICIALLY_ASSIGNED), /** * Azerbaijan * [AZ, AZE, 31, * Officially assigned] */ AZ("Azerbaijan", "AZE", 31, Assignment.OFFICIALLY_ASSIGNED), /** * Bosnia and Herzegovina * [BA, BIH, 70, * Officially assigned] */ BA("Bosnia and Herzegovina", "BIH", 70, Assignment.OFFICIALLY_ASSIGNED), /** * Barbados * [BB, BRB, 52, * Officially assigned] */ BB("Barbados", "BRB", 52, Assignment.OFFICIALLY_ASSIGNED), /** * Bangladesh * [BD, BGD, 50, * Officially assigned] */ BD("Bangladesh", "BGD", 50, Assignment.OFFICIALLY_ASSIGNED), /** * Belgium * [BE, BEL, 56, * Officially assigned] */ BE("Belgium", "BEL", 56, Assignment.OFFICIALLY_ASSIGNED), /** * Burkina Faso * [BF, BFA, 854, * Officially assigned] */ BF("Burkina Faso", "BFA", 854, Assignment.OFFICIALLY_ASSIGNED), /** * Bulgaria * [BG, BGR, 100, * Officially assigned] */ BG("Bulgaria", "BGR", 100, Assignment.OFFICIALLY_ASSIGNED), /** * Bahrain * [BH, BHR, 48, * Officially assigned] */ BH("Bahrain", "BHR", 48, Assignment.OFFICIALLY_ASSIGNED), /** * Burundi * [BI, BDI, 108, * Officially assigned] */ BI("Burundi", "BDI", 108, Assignment.OFFICIALLY_ASSIGNED), /** * Benin * [BJ, BEN, 204, * Officially assigned] */ BJ("Benin", "BEN", 204, Assignment.OFFICIALLY_ASSIGNED), /** * Saint Barthélemy * [BL, BLM, 652, * Officially assigned] */ BL("Saint Barth\u00E9lemy", "BLM", 652, Assignment.OFFICIALLY_ASSIGNED), /** * Bermuda * [BM, BMU, 60, * Officially assigned] */ BM("Bermuda", "BMU", 60, Assignment.OFFICIALLY_ASSIGNED), /** * Brunei Darussalam * [BN, BRN, 96, * Officially assigned] */ BN("Brunei Darussalam", "BRN", 96, Assignment.OFFICIALLY_ASSIGNED), /** * Bolivia, Plurinational State of * [BO, BOL, 68, * Officially assigned] */ BO("Bolivia, Plurinational State of", "BOL", 68, Assignment.OFFICIALLY_ASSIGNED), /** * Bonaire, Sint Eustatius and Saba * [BQ, BES, 535, * Officially assigned] */ BQ("Bonaire, Sint Eustatius and Saba", "BES", 535, Assignment.OFFICIALLY_ASSIGNED), /** * Brazil * [BR, BRA, 76, * Officially assigned] */ BR("Brazil", "BRA", 76, Assignment.OFFICIALLY_ASSIGNED), /** * Bahamas * [BS, BHS, 44, * Officially assigned] */ BS("Bahamas", "BHS", 44, Assignment.OFFICIALLY_ASSIGNED), /** * Bhutan * [BT, BTN, 64, * Officially assigned] */ BT("Bhutan", "BTN", 64, Assignment.OFFICIALLY_ASSIGNED), /** * Burma * [BU, BUMM, 104, * Officially assigned] * * @see #MM */ BU("Burma", "BUMM", 104, Assignment.TRANSITIONALLY_RESERVED), /** * Bouvet Island * [BV, BVT, 74, * Officially assigned] */ BV("Bouvet Island", "BVT", 74, Assignment.OFFICIALLY_ASSIGNED), /** * Botswana * [BW, BWA, 72, * Officially assigned] */ BW("Botswana", "BWA", 72, Assignment.OFFICIALLY_ASSIGNED), /** * Belarus * [BY, BLR, 112, * Officially assigned] */ BY("Belarus", "BLR", 112, Assignment.OFFICIALLY_ASSIGNED), /** * Belize * [BZ, BLZ, 84, * Officially assigned] */ BZ("Belize", "BLZ", 84, Assignment.OFFICIALLY_ASSIGNED), /** * Canada * [CA, CAN, 124, * Officially assigned] */ CA("Canada", "CAN", 124, Assignment.OFFICIALLY_ASSIGNED) { @Override public Locale toLocale() { return Locale.CANADA; } }, /** * Cocos (Keeling) Islands * [CC, CCK, 166, * Officially assigned] */ CC("Cocos (Keeling) Islands", "CCK", 166, Assignment.OFFICIALLY_ASSIGNED), /** * Congo, the Democratic Republic of the * [CD, COD, 180, * Officially assigned] */ CD("Congo, the Democratic Republic of the", "COD", 180, Assignment.OFFICIALLY_ASSIGNED), /** * Central African Republic * [CF, CAF, 140, * Officially assigned] */ CF("Central African Republic", "CAF", 140, Assignment.OFFICIALLY_ASSIGNED), /** * Congo * [CG, COG, 178, * Officially assigned] */ CG("Congo", "COG", 178, Assignment.OFFICIALLY_ASSIGNED), /** * Switzerland * [CH, CHE, 756, * Officially assigned] */ CH("Switzerland", "CHE", 756, Assignment.OFFICIALLY_ASSIGNED), /** * Côte d'Ivoire * [CI, CIV, 384, * Officially assigned] */ CI("C\u00F4te d'Ivoire", "CIV", 384, Assignment.OFFICIALLY_ASSIGNED), /** * Cook Islands * [CK, COK, 184, * Officially assigned] */ CK("Cook Islands", "COK", 184, Assignment.OFFICIALLY_ASSIGNED), /** * Chile * [CL, CHL, 152, * Officially assigned] */ CL("Chile", "CHL", 152, Assignment.OFFICIALLY_ASSIGNED), /** * Cameroon * [CM, CMR, 120, * Officially assigned] */ CM("Cameroon", "CMR", 120, Assignment.OFFICIALLY_ASSIGNED), /** * China * [CN, CHN, 156, * Officially assigned] */ CN("China", "CHN", 156, Assignment.OFFICIALLY_ASSIGNED) { @Override public Locale toLocale() { return Locale.CHINA; } }, /** * Colombia * [CO, COL, 170, * Officially assigned] */ CO("Colombia", "COL", 170, Assignment.OFFICIALLY_ASSIGNED), /** * Clipperton Island * [CP, CPT, -1, * Exceptionally reserved] */ CP("Clipperton Island", "CPT", -1, Assignment.EXCEPTIONALLY_RESERVED), /** * Costa Rica * [CR, CRI, 188, * Officially assigned] */ CR("Costa Rica", "CRI", 188, Assignment.OFFICIALLY_ASSIGNED), /** * Serbia and Montenegro * [CS, CSXX, 891, * Traditionally reserved] */ CS("Serbia and Montenegro", "CSXX", 891, Assignment.TRANSITIONALLY_RESERVED), /** * Cuba * [CU, CUB, 192, * Officially assigned] */ CU("Cuba", "CUB", 192, Assignment.OFFICIALLY_ASSIGNED), /** * Cape Verde * [CV, CPV, 132, * Officially assigned] */ CV("Cape Verde", "CPV", 132, Assignment.OFFICIALLY_ASSIGNED), /** * Curaçao * [CW, CUW, 531, * Officially assigned] */ CW("Cura\u00E7ao", "CUW", 531, Assignment.OFFICIALLY_ASSIGNED), /** * Christmas Island * [CX, CXR, 162, * Officially assigned] */ CX("Christmas Island", "CXR", 162, Assignment.OFFICIALLY_ASSIGNED), /** * Cyprus * [CY, CYP, 196, * Officially assigned] */ CY("Cyprus", "CYP", 196, Assignment.OFFICIALLY_ASSIGNED), /** * Czech Republic * [CZ, CZE, 203, * Officially assigned] */ CZ("Czech Republic", "CZE", 203, Assignment.OFFICIALLY_ASSIGNED), /** * Germany * [DE, DEU, 276, * Officially assigned] */ DE("Germany", "DEU", 276, Assignment.OFFICIALLY_ASSIGNED) { @Override public Locale toLocale() { return Locale.GERMANY; } }, /** * Diego Garcia * [DG, DGA, -1, * Exceptionally reserved] */ DG("Diego Garcia", "DGA", -1, Assignment.EXCEPTIONALLY_RESERVED), /** * Djibouti * [DJ, DJI, 262, * Officially assigned] */ DJ("Djibouti", "DJI", 262, Assignment.OFFICIALLY_ASSIGNED), /** * Denmark * [DK, DNK, 208, * Officially assigned] */ DK("Denmark", "DNK", 208, Assignment.OFFICIALLY_ASSIGNED), /** * Dominica * [DM, DMA, 212, * Officially assigned] */ DM("Dominica", "DMA", 212, Assignment.OFFICIALLY_ASSIGNED), /** * Dominican Republic * [DO, DOM, 214, * Officially assigned] */ DO("Dominican Republic", "DOM", 214, Assignment.OFFICIALLY_ASSIGNED), /** * Algeria * [DZ, DZA, 12, * Officially assigned] */ DZ("Algeria", "DZA", 12, Assignment.OFFICIALLY_ASSIGNED), /** * Ceuta, * Melilla * [EA, null, -1, * Exceptionally reserved] */ EA("Ceuta, Melilla", null, -1, Assignment.EXCEPTIONALLY_RESERVED), /** * Ecuador * [EC, ECU, 218, * Officially assigned] */ EC("Ecuador", "ECU", 218, Assignment.OFFICIALLY_ASSIGNED), /** * Estonia * [EE, EST, 233, * Officially assigned] */ EE("Estonia", "EST", 233, Assignment.OFFICIALLY_ASSIGNED), /** * Egypt * [EG, EGY, 818, * Officially assigned] */ EG("Egypt", "EGY", 818, Assignment.OFFICIALLY_ASSIGNED), /** * Western Sahara * [EH, ESH, 732, * Officially assigned] */ EH("Western Sahara", "ESH", 732, Assignment.OFFICIALLY_ASSIGNED), /** * Eritrea * [ER, ERI, 232, * Officially assigned] */ ER("Eritrea", "ERI", 232, Assignment.OFFICIALLY_ASSIGNED), /** * Spain * [ES, ESP, 724, * Officially assigned] */ ES("Spain", "ESP", 724, Assignment.OFFICIALLY_ASSIGNED), /** * Ethiopia * [ET, ETH, 231, * Officially assigned] */ ET("Ethiopia", "ETH", 231, Assignment.OFFICIALLY_ASSIGNED), /** * European Union * [EU, null, -1, * Exceptionally reserved] */ EU("European Union", null, -1, Assignment.EXCEPTIONALLY_RESERVED), /** * Finland * [FI, FIN, 246, * Officially assigned] * * @see #SF */ FI("Finland", "FIN", 246, Assignment.OFFICIALLY_ASSIGNED), /** * Fiji * [FJ, FJI, 242, * Officially assigned] */ FJ("Fiji", "FJI", 242, Assignment.OFFICIALLY_ASSIGNED), /** * Falkland Islands (Malvinas) * [FK, FLK, 238, * Officially assigned] */ FK("Falkland Islands (Malvinas)", "FLK", 238, Assignment.OFFICIALLY_ASSIGNED), /** * Micronesia, Federated States of * [FM, FSM, 583, * Officially assigned] */ FM("Micronesia, Federated States of", "FSM", 583, Assignment.OFFICIALLY_ASSIGNED), /** * Faroe Islands * [FO, FRO, 234, * Officially assigned] */ FO("Faroe Islands", "FRO", 234, Assignment.OFFICIALLY_ASSIGNED), /** * France * [FR, FRA, 250, * Officially assigned] */ FR("France", "FRA", 250, Assignment.OFFICIALLY_ASSIGNED) { @Override public Locale toLocale() { return Locale.FRANCE; } }, /** * France, Metropolitan * [FX, FXX, -1, * Exceptionally reserved] */ FX("France, Metropolitan", "FXX", -1, Assignment.EXCEPTIONALLY_RESERVED), /** * Gabon * [GA, GAB, 266, * Officially assigned] */ GA("Gabon", "GAB", 266, Assignment.OFFICIALLY_ASSIGNED), /** * United Kingdom * [GB, GBR, 826, * Officially assigned] */ GB("United Kingdom", "GBR", 826, Assignment.OFFICIALLY_ASSIGNED) { @Override public Locale toLocale() { return Locale.UK; } }, /** * Grenada * [GD, GRD, 308, * Officially assigned] */ GD("Grenada", "GRD", 308, Assignment.OFFICIALLY_ASSIGNED), /** * Georgia * [GE, GEO, 268, * Officially assigned] */ GE("Georgia", "GEO", 268, Assignment.OFFICIALLY_ASSIGNED), /** * French Guiana * [GF, GUF, 254, * Officially assigned] */ GF("French Guiana", "GUF", 254, Assignment.OFFICIALLY_ASSIGNED), /** * Guernsey * [GG, GGY, 831, * Officially assigned] */ GG("Guernsey", "GGY", 831, Assignment.OFFICIALLY_ASSIGNED), /** * Ghana * [GH, GHA, 288, * Officially assigned] */ GH("Ghana", "GHA", 288, Assignment.OFFICIALLY_ASSIGNED), /** * Gibraltar * [GI, GIB, 292, * Officially assigned] */ GI("Gibraltar", "GIB", 292, Assignment.OFFICIALLY_ASSIGNED), /** * Greenland * [GL, GRL, 304, * Officially assigned] */ GL("Greenland", "GRL", 304, Assignment.OFFICIALLY_ASSIGNED), /** * Gambia * [GM, GMB, 270, * Officially assigned] */ GM("Gambia", "GMB", 270, Assignment.OFFICIALLY_ASSIGNED), /** * Guinea * [GN, GIN, 324, * Officially assigned] */ GN("Guinea", "GIN", 324, Assignment.OFFICIALLY_ASSIGNED), /** * Guadeloupe * [GP, GLP, 312, * Officially assigned] */ GP("Guadeloupe", "GLP", 312, Assignment.OFFICIALLY_ASSIGNED), /** * Equatorial Guinea * [GQ, GNQ, 226, * Officially assigned] */ GQ("Equatorial Guinea", "GNQ", 226, Assignment.OFFICIALLY_ASSIGNED), /** * Greece * [GR, GRC, 300, * Officially assigned] */ GR("Greece", "GRC", 300, Assignment.OFFICIALLY_ASSIGNED), /** * South Georgia and the South Sandwich Islands * [GS, SGS, 239, * Officially assigned] */ GS("South Georgia and the South Sandwich Islands", "SGS", 239, Assignment.OFFICIALLY_ASSIGNED), /** * Guatemala * [GT, GTM, 320, * Officially assigned] */ GT("Guatemala", "GTM", 320, Assignment.OFFICIALLY_ASSIGNED), /** * Guam * [GU, GUM, 316, * Officially assigned] */ GU("Guam", "GUM", 316, Assignment.OFFICIALLY_ASSIGNED), /** * Guinea-Bissau * [GW, GNB, 624, * Officially assigned] */ GW("Guinea-Bissau", "GNB", 624, Assignment.OFFICIALLY_ASSIGNED), /** * Guyana * [GY, GUY, 328, * Officially assigned] */ GY("Guyana", "GUY", 328, Assignment.OFFICIALLY_ASSIGNED), /** * Hong Kong * [HK, HKG, 344, * Officially assigned] */ HK("Hong Kong", "HKG", 344, Assignment.OFFICIALLY_ASSIGNED), /** * Heard Island and McDonald Islands * [HM, HMD, 334, * Officially assigned] */ HM("Heard Island and McDonald Islands", "HMD", 334, Assignment.OFFICIALLY_ASSIGNED), /** * Honduras * [HN, HND, 340, * Officially assigned] */ HN("Honduras", "HND", 340, Assignment.OFFICIALLY_ASSIGNED), /** * Croatia * [HR, HRV, 191, * Officially assigned] */ HR("Croatia", "HRV", 191, Assignment.OFFICIALLY_ASSIGNED), /** * Haiti * [HT, HTI, 332, * Officially assigned] */ HT("Haiti", "HTI", 332, Assignment.OFFICIALLY_ASSIGNED), /** * Hungary * [HU, HUN, 348, * Officially assigned] */ HU("Hungary", "HUN", 348, Assignment.OFFICIALLY_ASSIGNED), /** * Canary Islands * [IC, null, -1, * Exceptionally reserved] */ IC("Canary Islands", null, -1, Assignment.EXCEPTIONALLY_RESERVED), /** * Indonesia * [ID, IDN, 360, * Officially assigned] */ ID("Indonesia", "IDN", 360, Assignment.OFFICIALLY_ASSIGNED), /** * Ireland * [IE, IRL, 372, * Officially assigned] */ IE("Ireland", "IRL", 372, Assignment.OFFICIALLY_ASSIGNED), /** * Israel * [IL, ISR, 376, * Officially assigned] */ IL("Israel", "ISR", 376, Assignment.OFFICIALLY_ASSIGNED), /** * Isle of Man * [IM, IMN, 833, * Officially assigned] */ IM("Isle of Man", "IMN", 833, Assignment.OFFICIALLY_ASSIGNED), /** * India * [IN, IND, 356, * Officially assigned] */ IN("India", "IND", 356, Assignment.OFFICIALLY_ASSIGNED), /** * British Indian Ocean Territory * [IO, IOT, 86, * Officially assigned] */ IO("British Indian Ocean Territory", "IOT", 86, Assignment.OFFICIALLY_ASSIGNED), /** * Iraq * [IQ, IRQ, 368, * Officially assigned] */ IQ("Iraq", "IRQ", 368, Assignment.OFFICIALLY_ASSIGNED), /** * Iran, Islamic Republic of * [IR, IRN, 364, * Officially assigned] */ IR("Iran, Islamic Republic of", "IRN", 364, Assignment.OFFICIALLY_ASSIGNED), /** * Iceland * [IS, ISL, 352, * Officially assigned] */ IS("Iceland", "ISL", 352, Assignment.OFFICIALLY_ASSIGNED), /** * Italy * [IT, ITA, 380, * Officially assigned] */ IT("Italy", "ITA", 380, Assignment.OFFICIALLY_ASSIGNED) { @Override public Locale toLocale() { return Locale.ITALY; } }, /** * Jersey * [JE, JEY, 832, * Officially assigned] */ JE("Jersey", "JEY", 832, Assignment.OFFICIALLY_ASSIGNED), /** * Jamaica * [JM, JAM, 388, * Officially assigned] */ JM("Jamaica", "JAM", 388, Assignment.OFFICIALLY_ASSIGNED), /** * Jordan * [JO, JOR, 400, * Officially assigned] */ JO("Jordan", "JOR", 400, Assignment.OFFICIALLY_ASSIGNED), /** * Japan * [JP, JPN, 392, * Officially assigned] */ JP("Japan", "JPN", 392, Assignment.OFFICIALLY_ASSIGNED) { @Override public Locale toLocale() { return Locale.JAPAN; } }, /** * Kenya * [KE, KEN, 404, * Officially assigned] */ KE("Kenya", "KEN", 404, Assignment.OFFICIALLY_ASSIGNED), /** * Kyrgyzstan * [KG, KGZ, 417, * Officially assigned] */ KG("Kyrgyzstan", "KGZ", 417, Assignment.OFFICIALLY_ASSIGNED), /** * Cambodia * [KH, KHM, 116, * Officially assigned] */ KH("Cambodia", "KHM", 116, Assignment.OFFICIALLY_ASSIGNED), /** * Kiribati * [KI, KIR, 296, * Officially assigned] */ KI("Kiribati", "KIR", 296, Assignment.OFFICIALLY_ASSIGNED), /** * Comoros * [KM, COM, 174, * Officially assigned] */ KM("Comoros", "COM", 174, Assignment.OFFICIALLY_ASSIGNED), /** * Saint Kitts and Nevis * [KN, KNA, 659, * Officially assigned] */ KN("Saint Kitts and Nevis", "KNA", 659, Assignment.OFFICIALLY_ASSIGNED), /** * Korea, Democratic People's Republic of * [KP, PRK, 408, * Officially assigned] */ KP("Korea, Democratic People's Republic of", "PRK", 408, Assignment.OFFICIALLY_ASSIGNED), /** * Korea, Republic of * [KR, KOR, 410, * Officially assigned] */ KR("Korea, Republic of", "KOR", 410, Assignment.OFFICIALLY_ASSIGNED) { @Override public Locale toLocale() { return Locale.KOREA; } }, /** * Kuwait * [KW, KWT, 414, * Officially assigned] */ KW("Kuwait", "KWT", 414, Assignment.OFFICIALLY_ASSIGNED), /** * Cayman Islands * [KY, CYM, 136, * Officially assigned] */ KY("Cayman Islands", "CYM", 136, Assignment.OFFICIALLY_ASSIGNED), /** * Kazakhstan * [KZ, KAZ, 398, * Officially assigned] */ KZ("Kazakhstan", "KAZ", 398, Assignment.OFFICIALLY_ASSIGNED), /** * Lao People's Democratic Republic * [LA, LAO, 418, * Officially assigned] */ LA("Lao People's Democratic Republic", "LAO", 418, Assignment.OFFICIALLY_ASSIGNED), /** * Lebanon * [LB, LBN, 422, * Officially assigned] */ LB("Lebanon", "LBN", 422, Assignment.OFFICIALLY_ASSIGNED), /** * Saint Lucia * [LC, LCA, 662, * Officially assigned] */ LC("Saint Lucia", "LCA", 662, Assignment.OFFICIALLY_ASSIGNED), /** * Liechtenstein * [LI, LIE, 438, * Officially assigned] */ LI("Liechtenstein", "LIE", 438, Assignment.OFFICIALLY_ASSIGNED), /** * Sri Lanka * [LK, LKA, 144, * Officially assigned] */ LK("Sri Lanka", "LKA", 144, Assignment.OFFICIALLY_ASSIGNED), /** * Liberia * [LR, LBR, 430, * Officially assigned] */ LR("Liberia", "LBR", 430, Assignment.OFFICIALLY_ASSIGNED), /** * Lesotho * [LS, LSO, 426, * Officially assigned] */ LS("Lesotho", "LSO", 426, Assignment.OFFICIALLY_ASSIGNED), /** * Lithuania * [LT, LTU, 440, * Officially assigned] */ LT("Lithuania", "LTU", 440, Assignment.OFFICIALLY_ASSIGNED), /** * Luxembourg * [LU, LUX, 442, * Officially assigned] */ LU("Luxembourg", "LUX", 442, Assignment.OFFICIALLY_ASSIGNED), /** * Latvia * [LV, LVA, 428, * Officially assigned] */ LV("Latvia", "LVA", 428, Assignment.OFFICIALLY_ASSIGNED), /** * Libya * [LY, LBY, 434, * Officially assigned] */ LY("Libya", "LBY", 434, Assignment.OFFICIALLY_ASSIGNED), /** * Morocco * [MA, MAR, 504, * Officially assigned] */ MA("Morocco", "MAR", 504, Assignment.OFFICIALLY_ASSIGNED), /** * Monaco * [MC, MCO, 492, * Officially assigned] */ MC("Monaco", "MCO", 492, Assignment.OFFICIALLY_ASSIGNED), /** * Moldova, Republic of * [MD, MDA, 498, * Officially assigned] */ MD("Moldova, Republic of", "MDA", 498, Assignment.OFFICIALLY_ASSIGNED), /** * Montenegro * [ME, MNE, 499, * Officially assigned] */ ME("Montenegro", "MNE", 499, Assignment.OFFICIALLY_ASSIGNED), /** * Saint Martin (French part) * [MF, MAF, 663, * Officially assigned] */ MF("Saint Martin (French part)", "MAF", 663, Assignment.OFFICIALLY_ASSIGNED), /** * Madagascar * [MG, MDG, 450, * Officially assigned] */ MG("Madagascar", "MDG", 450, Assignment.OFFICIALLY_ASSIGNED), /** * Marshall Islands * [MH, MHL, 584, * Officially assigned] */ MH("Marshall Islands", "MHL", 584, Assignment.OFFICIALLY_ASSIGNED), /** * Macedonia, the former Yugoslav Republic of * [MK, MKD, 807, * Officially assigned] */ MK("Macedonia, the former Yugoslav Republic of", "MKD", 807, Assignment.OFFICIALLY_ASSIGNED), /** * Mali * [ML, MLI, 466, * Officially assigned] */ ML("Mali", "MLI", 466, Assignment.OFFICIALLY_ASSIGNED), /** * Myanmar * [MM, MMR, 104, * Officially assigned] * * @see #BU */ MM("Myanmar", "MMR", 104, Assignment.OFFICIALLY_ASSIGNED), /** * Mongolia * [MN, MNG, 496, * Officially assigned] */ MN("Mongolia", "MNG", 496, Assignment.OFFICIALLY_ASSIGNED), /** * Macao * [MO, MCO, 492, * Officially assigned] */ MO("Macao", "MAC", 446, Assignment.OFFICIALLY_ASSIGNED), /** * Northern Mariana Islands * [MP, MNP, 580, * Officially assigned] */ MP("Northern Mariana Islands", "MNP", 580, Assignment.OFFICIALLY_ASSIGNED), /** * Martinique * [MQ, MTQ, 474, * Officially assigned] */ MQ("Martinique", "MTQ", 474, Assignment.OFFICIALLY_ASSIGNED), /** * Mauritania * [MR, MRT, 478, * Officially assigned] */ MR("Mauritania", "MRT", 478, Assignment.OFFICIALLY_ASSIGNED), /** * Montserrat * [MS, MSR, 500, * Officially assigned] */ MS("Montserrat", "MSR", 500, Assignment.OFFICIALLY_ASSIGNED), /** * Malta * [MT, MLT, 470, * Officially assigned] */ MT("Malta", "MLT", 470, Assignment.OFFICIALLY_ASSIGNED), /** * Mauritius * [MU, MUS, 480, * Officially assigned]] */ MU("Mauritius", "MUS", 480, Assignment.OFFICIALLY_ASSIGNED), /** * Maldives * [MV, MDV, 462, * Officially assigned] */ MV("Maldives", "MDV", 462, Assignment.OFFICIALLY_ASSIGNED), /** * Malawi * [MW, MWI, 454, * Officially assigned] */ MW("Malawi", "MWI", 454, Assignment.OFFICIALLY_ASSIGNED), /** * Mexico * [MX, MEX, 484, * Officially assigned] */ MX("Mexico", "MEX", 484, Assignment.OFFICIALLY_ASSIGNED), /** * Malaysia * [MY, MYS, 458, * Officially assigned] */ MY("Malaysia", "MYS", 458, Assignment.OFFICIALLY_ASSIGNED), /** * Mozambique * [MZ, MOZ, 508, * Officially assigned] */ MZ("Mozambique", "MOZ", 508, Assignment.OFFICIALLY_ASSIGNED), /** * Namibia * [NA, NAM, 516, * Officially assigned] */ NA("Namibia", "NAM", 516, Assignment.OFFICIALLY_ASSIGNED), /** * New Caledonia * [NC, NCL, 540, * Officially assigned] */ NC("New Caledonia", "NCL", 540, Assignment.OFFICIALLY_ASSIGNED), /** * Niger * [NE, NER, 562, * Officially assigned] */ NE("Niger", "NER", 562, Assignment.OFFICIALLY_ASSIGNED), /** * Norfolk Island * [NF, NFK, 574, * Officially assigned] */ NF("Norfolk Island", "NFK", 574, Assignment.OFFICIALLY_ASSIGNED), /** * Nigeria * [NG, NGA, 566, * Officially assigned] */ NG("Nigeria","NGA", 566, Assignment.OFFICIALLY_ASSIGNED), /** * Nicaragua * [NI, NIC, 558, * Officially assigned] */ NI("Nicaragua", "NIC", 558, Assignment.OFFICIALLY_ASSIGNED), /** * Netherlands * [NL, NLD, 528, * Officially assigned] */ NL("Netherlands", "NLD", 528, Assignment.OFFICIALLY_ASSIGNED), /** * Norway * [NO, NOR, 578, * Officially assigned] */ NO("Norway", "NOR", 578, Assignment.OFFICIALLY_ASSIGNED), /** * Nepal * [NP, NPL, 524, * Officially assigned] */ NP("Nepal", "NPL", 524, Assignment.OFFICIALLY_ASSIGNED), /** * Nauru * [NR, NRU, 520, * Officially assigned] */ NR("Nauru", "NRU", 520, Assignment.OFFICIALLY_ASSIGNED), /** * Neutral Zone * [NT, NTHH, 536, * Traditionally reserved] */ NT("Neutral Zone", "NTHH", 536, Assignment.TRANSITIONALLY_RESERVED), /** * Niue * [NU, NIU, 570, * Officially assigned] */ NU("Niue", "NIU", 570, Assignment.OFFICIALLY_ASSIGNED), /** * New Zealand * [NZ, NZL, 554, * Officially assigned] */ NZ("New Zealand", "NZL", 554, Assignment.OFFICIALLY_ASSIGNED), /** * Oman * [OM, OMN, 512, * Officially assigned] */ OM("Oman", "OMN", 512, Assignment.OFFICIALLY_ASSIGNED), /** * Panama * [PA, PAN, 591, * Officially assigned] */ PA("Panama", "PAN", 591, Assignment.OFFICIALLY_ASSIGNED), /** * Peru * [PE, PER, 604, * Officially assigned] */ PE("Peru", "PER", 604, Assignment.OFFICIALLY_ASSIGNED), /** * French Polynesia * [PF, PYF, 258, * Officially assigned] */ PF("French Polynesia", "PYF", 258, Assignment.OFFICIALLY_ASSIGNED), /** * Papua New Guinea * [PG, PNG, 598, * Officially assigned] */ PG("Papua New Guinea", "PNG", 598, Assignment.OFFICIALLY_ASSIGNED), /** * Philippines * [PH, PHL, 608, * Officially assigned] */ PH("Philippines", "PHL", 608, Assignment.OFFICIALLY_ASSIGNED), /** * Pakistan * [PK, PAK, 586, * Officially assigned] */ PK("Pakistan", "PAK", 586, Assignment.OFFICIALLY_ASSIGNED), /** * Poland * [PL, POL, 616, * Officially assigned] */ PL("Poland", "POL", 616, Assignment.OFFICIALLY_ASSIGNED), /** * Saint Pierre and Miquelon * [PM, SPM, 666, * Officially assigned] */ PM("Saint Pierre and Miquelon", "SPM", 666, Assignment.OFFICIALLY_ASSIGNED), /** * Pitcairn * [PN, PCN, 612, * Officially assigned] */ PN("Pitcairn", "PCN", 612, Assignment.OFFICIALLY_ASSIGNED), /** * Puerto Rico * [PR, PRI, 630, * Officially assigned] */ PR("Puerto Rico", "PRI", 630, Assignment.OFFICIALLY_ASSIGNED), /** * Palestine, State of * [PS, PSE, 275, * Officially assigned] */ PS("Palestine, State of", "PSE", 275, Assignment.OFFICIALLY_ASSIGNED), /** * Portugal * [PT, PRT, 620, * Officially assigned] */ PT("Portugal", "PRT", 620, Assignment.OFFICIALLY_ASSIGNED), /** * Palau * [PW, PLW, 585, * Officially assigned] */ PW("Palau", "PLW", 585, Assignment.OFFICIALLY_ASSIGNED), /** * Paraguay * [PY, PRY, 600, * Officially assigned] */ PY("Paraguay", "PRY", 600, Assignment.OFFICIALLY_ASSIGNED), /** * Qatar * [QA, QAT, 634, * Officially assigned] */ QA("Qatar", "QAT", 634, Assignment.OFFICIALLY_ASSIGNED), /** * Réunion * [RE, REU, 638, * Officially assigned] */ RE("R\u00E9union", "REU", 638, Assignment.OFFICIALLY_ASSIGNED), /** * Romania * [RO, ROU, 642, * Officially assigned] */ RO("Romania", "ROU", 642, Assignment.OFFICIALLY_ASSIGNED), /** * Serbia * [RS, SRB, 688, * Officially assigned] */ RS("Serbia", "SRB", 688, Assignment.OFFICIALLY_ASSIGNED), /** * Russian Federation * [RU, RUS, 643, * Officially assigned] */ RU("Russian Federation", "RUS", 643, Assignment.OFFICIALLY_ASSIGNED), /** * Rwanda * [RW, RWA, 646, * Officially assigned] */ RW("Rwanda", "RWA", 646, Assignment.OFFICIALLY_ASSIGNED), /** * Saudi Arabia * [SA, SAU, 682, * Officially assigned] */ SA("Saudi Arabia", "SAU", 682, Assignment.OFFICIALLY_ASSIGNED), /** * Solomon Islands * [SB, SLB, 90, * Officially assigned] */ SB("Solomon Islands", "SLB", 90, Assignment.OFFICIALLY_ASSIGNED), /** * Seychelles * [SC, SYC, 690, * Officially assigned] */ SC("Seychelles", "SYC", 690, Assignment.OFFICIALLY_ASSIGNED), /** * Sudan * [SD, SDN, 729, * Officially assigned] */ SD("Sudan", "SDN", 729, Assignment.OFFICIALLY_ASSIGNED), /** * Sweden * [SE, SWE, 752, * Officially assigned] */ SE("Sweden", "SWE", 752, Assignment.OFFICIALLY_ASSIGNED), /** * Finland * [SF, FIN, 246, * Traditionally reserved] * * @see #FI */ SF("Finland", "FIN", 246, Assignment.TRANSITIONALLY_RESERVED), /** * Singapore * [SG, SGP, 702, * Officially assigned] */ SG("Singapore", "SGP", 702, Assignment.OFFICIALLY_ASSIGNED), /** * Saint Helena, Ascension and Tristan da Cunha * [SH, SHN, 654, * Officially assigned] */ SH("Saint Helena, Ascension and Tristan da Cunha", "SHN", 654, Assignment.OFFICIALLY_ASSIGNED), /** * Slovenia * [SI, SVN, 705, * Officially assigned] */ SI("Slovenia", "SVN", 705, Assignment.OFFICIALLY_ASSIGNED), /** * Svalbard and Jan Mayen * [SJ, SJM, 744, * Officially assigned] */ SJ("Svalbard and Jan Mayen", "SJM", 744, Assignment.OFFICIALLY_ASSIGNED), /** * Slovakia * [SK, SVK, 703, * Officially assigned] */ SK("Slovakia", "SVK", 703, Assignment.OFFICIALLY_ASSIGNED), /** * Sierra Leone * [SL, SLE, 694, * Officially assigned] */ SL("Sierra Leone", "SLE", 694, Assignment.OFFICIALLY_ASSIGNED), /** * San Marino * [SM, SMR, 674, * Officially assigned] */ SM("San Marino", "SMR", 674, Assignment.OFFICIALLY_ASSIGNED), /** * Senegal * [SN, SEN, 686, * Officially assigned] */ SN("Senegal", "SEN", 686, Assignment.OFFICIALLY_ASSIGNED), /** * Somalia * [SO, SOM, 706, * Officially assigned] */ SO("Somalia", "SOM", 706, Assignment.OFFICIALLY_ASSIGNED), /** * Suriname * [SR, SUR, 740, * Officially assigned] */ SR("Suriname", "SUR", 740, Assignment.OFFICIALLY_ASSIGNED), /** * South Sudan * [SS, SSD, 728, * Officially assigned] */ SS("South Sudan", "SSD", 728, Assignment.OFFICIALLY_ASSIGNED), /** * Sao Tome and Principe * [ST, STP, 678, * Officially assigned] */ ST("Sao Tome and Principe", "STP", 678, Assignment.OFFICIALLY_ASSIGNED), /** * USSR * [SU, SUN, -1, * Exceptionally reserved] */ SU("USSR", "SUN", -1, Assignment.EXCEPTIONALLY_RESERVED), /** * El Salvador * [SV, SLV, 222, * Officially assigned] */ SV("El Salvador", "SLV", 222, Assignment.OFFICIALLY_ASSIGNED), /** * Sint Maarten (Dutch part) * [SX, SXM, 534, * Officially assigned] */ SX("Sint Maarten (Dutch part)", "SXM", 534, Assignment.OFFICIALLY_ASSIGNED), /** * Syrian Arab Republic * [SY, SYR, 760, * Officially assigned] */ SY("Syrian Arab Republic", "SYR", 760, Assignment.OFFICIALLY_ASSIGNED), /** * Swaziland * [SZ, SWZ, 748, * Officially assigned] */ SZ("Swaziland", "SWZ", 748, Assignment.OFFICIALLY_ASSIGNED), /** * Tristan da Cunha * [TA, TAA, -1, * Exceptionally reserved. */ TA("Tristan da Cunha", "TAA", -1, Assignment.EXCEPTIONALLY_RESERVED), /** * Turks and Caicos Islands * [TC, TCA, 796, * Officially assigned] */ TC("Turks and Caicos Islands", "TCA", 796, Assignment.OFFICIALLY_ASSIGNED), /** * Chad * [TD, TCD, 148, * Officially assigned] */ TD("Chad", "TCD", 148, Assignment.OFFICIALLY_ASSIGNED), /** * French Southern Territories * [TF, ATF, 260, * Officially assigned] */ TF("French Southern Territories", "ATF", 260, Assignment.OFFICIALLY_ASSIGNED), /** * Togo * [TG, TGO, 768, * Officially assigned] */ TG("Togo", "TGO", 768, Assignment.OFFICIALLY_ASSIGNED), /** * Thailand * [TH, THA, 764, * Officially assigned] */ TH("Thailand", "THA", 764, Assignment.OFFICIALLY_ASSIGNED), /** * Tajikistan * [TJ, TJK, 762, * Officially assigned] */ TJ("Tajikistan", "TJK", 762, Assignment.OFFICIALLY_ASSIGNED), /** * Tokelau * [TK, TKL, 772, * Officially assigned] */ TK("Tokelau", "TKL", 772, Assignment.OFFICIALLY_ASSIGNED), /** * Timor-Leste * [TL, TLS, 626, * Officially assigned] */ TL("Timor-Leste", "TLS", 626, Assignment.OFFICIALLY_ASSIGNED), /** * Turkmenistan * [TM, TKM, 795, * Officially assigned] */ TM("Turkmenistan", "TKM", 795, Assignment.OFFICIALLY_ASSIGNED), /** * Tunisia * [TN, TUN, 788, * Officially assigned] */ TN("Tunisia", "TUN", 788, Assignment.OFFICIALLY_ASSIGNED), /** * Tonga * [TO, TON, 776, * Officially assigned] */ TO("Tonga", "TON", 776, Assignment.OFFICIALLY_ASSIGNED), /** * East Timor * [TP, TPTL, 0, * Traditionally reserved] * *

* ISO 3166-1 numeric code is unknown. *

*/ TP("East Timor", "TPTL", 0, Assignment.TRANSITIONALLY_RESERVED), /** * Turkey * [TR, TUR, 792, * Officially assigned] */ TR("Turkey", "TUR", 792, Assignment.OFFICIALLY_ASSIGNED), /** * Trinidad and Tobago * [TT, TTO, 780, * Officially assigned] */ TT("Trinidad and Tobago", "TTO", 780, Assignment.OFFICIALLY_ASSIGNED), /** * Tuvalu * [TV, TUV, 798, * Officially assigned] */ TV("Tuvalu", "TUV", 798, Assignment.OFFICIALLY_ASSIGNED), /** * Taiwan, Province of China * [TW, TWN, 158, * Officially assigned] */ TW("Taiwan, Province of China", "TWN", 158, Assignment.OFFICIALLY_ASSIGNED) { @Override public Locale toLocale() { return Locale.TAIWAN; } }, /** * Tanzania, United Republic of * [TZ, TZA, 834, * Officially assigned] */ TZ("Tanzania, United Republic of", "TZA", 834, Assignment.OFFICIALLY_ASSIGNED), /** * Ukraine * [UA, UKR, 804, * Officially assigned] */ UA("Ukraine", "UKR", 804, Assignment.OFFICIALLY_ASSIGNED), /** * Uganda * [UG, UGA, 800, * Officially assigned] */ UG("Uganda", "UGA", 800, Assignment.OFFICIALLY_ASSIGNED), /** * United Kingdom * [UK, null, -1, * Exceptionally reserved] */ UK("United Kingdom", null, -1, Assignment.EXCEPTIONALLY_RESERVED) { @Override public Locale toLocale() { return Locale.UK; } }, /** * United States Minor Outlying Islands * [UM, UMI, 581, * Officially assigned] */ UM("United States Minor Outlying Islands", "UMI", 581, Assignment.OFFICIALLY_ASSIGNED), /** * United States * [US, USA, 840, * Officially assigned] */ US("United States", "USA", 840, Assignment.OFFICIALLY_ASSIGNED) { @Override public Locale toLocale() { return Locale.US; } }, /** * Uruguay * [UY, URY, 858, * Officially assigned] */ UY("Uruguay", "URY", 858, Assignment.OFFICIALLY_ASSIGNED), /** * Uzbekistan * [UZ, UZB, 860, * Officially assigned] */ UZ("Uzbekistan", "UZB", 860, Assignment.OFFICIALLY_ASSIGNED), /** * Holy See (Vatican City State) * [VA, VAT, 336, * Officially assigned] */ VA("Holy See (Vatican City State)", "VAT", 336, Assignment.OFFICIALLY_ASSIGNED), /** * Saint Vincent and the Grenadines * [VC, VCT, 670, * Officially assigned] */ VC("Saint Vincent and the Grenadines", "VCT", 670, Assignment.OFFICIALLY_ASSIGNED), /** * Venezuela, Bolivarian Republic of * [VE, VEN, 862, * Officially assigned] */ VE("Venezuela, Bolivarian Republic of", "VEN", 862, Assignment.OFFICIALLY_ASSIGNED), /** * Virgin Islands, British * [VG, VGB, 92, * Officially assigned] */ VG("Virgin Islands, British", "VGB", 92, Assignment.OFFICIALLY_ASSIGNED), /** * Virgin Islands, U.S. * [VI, VIR, 850, * Officially assigned] */ VI("Virgin Islands, U.S.", "VIR", 850, Assignment.OFFICIALLY_ASSIGNED), /** * Viet Nam * [VN, VNM, 704, * Officially assigned] */ VN("Viet Nam", "VNM", 704, Assignment.OFFICIALLY_ASSIGNED), /** * Vanuatu * [VU, VUT, 548, * Officially assigned] */ VU("Vanuatu", "VUT", 548, Assignment.OFFICIALLY_ASSIGNED), /** * Wallis and Futuna * [WF, WLF, 876, * Officially assigned] */ WF("Wallis and Futuna", "WLF", 876, Assignment.OFFICIALLY_ASSIGNED), /** * Samoa * [WS, WSM, 882, * Officially assigned] */ WS("Samoa", "WSM", 882, Assignment.OFFICIALLY_ASSIGNED), /** * Kosovo, Republic of * [XK, XXK, -1, * User assigned] */ XK("Kosovo, Republic of", "XXK", -1, Assignment.USER_ASSIGNED), /** * Yemen * [YE, YEM, 887, * Officially assigned] */ YE("Yemen", "YEM", 887, Assignment.OFFICIALLY_ASSIGNED), /** * Mayotte * [YT, MYT, 175, * Officially assigned] */ YT("Mayotte", "MYT", 175, Assignment.OFFICIALLY_ASSIGNED), /** * Yugoslavia * [YU, YUCS, 890, * Traditionally reserved] */ YU("Yugoslavia", "YUCS", 890, Assignment.TRANSITIONALLY_RESERVED), /** * South Africa * [ZA, ZAF, 710, * Officially assigned] */ ZA("South Africa", "ZAF", 710, Assignment.OFFICIALLY_ASSIGNED), /** * Zambia * [ZM, ZMB, 894, * Officially assigned] */ ZM("Zambia", "ZMB", 894, Assignment.OFFICIALLY_ASSIGNED), /** * Zaire * [ZR, ZRCD, 0, * Traditionally reserved] * *

* ISO 3166-1 numeric code is unknown. *

*/ ZR("Zaire", "ZRCD", 0, Assignment.TRANSITIONALLY_RESERVED), /** * Zimbabwe * [ZW, ZWE, 716, * Officially assigned] */ ZW("Zimbabwe", "ZWE", 716, Assignment.OFFICIALLY_ASSIGNED), ; /** * Code assignment state in ISO 3166-1. * * @see Decoding table of ISO 3166-1 alpha-2 codes */ enum Assignment { /** * Officially assigned. * * Assigned to a country, territory, or area of geographical interest. */ OFFICIALLY_ASSIGNED, /** * User assigned. * * Free for assignment at the disposal of users. */ USER_ASSIGNED, /** * Exceptionally reserved. * * Reserved on request for restricted use. */ EXCEPTIONALLY_RESERVED, /** * Transitionally reserved. * * Deleted from ISO 3166-1 but reserved transitionally. */ TRANSITIONALLY_RESERVED, /** * Indeterminately reserved. * * Used in coding systems associated with ISO 3166-1. */ INDETERMINATELY_RESERVED, /** * Not used. * * Not used in ISO 3166-1 in deference to international property * organization names. */ NOT_USED } private static final Map alpha3Map = new HashMap<>(); private static final Map numericMap = new HashMap<>(); static { for (LDCountryCode cc : values()) { if (cc.getAlpha3() != null) { alpha3Map.put(cc.getAlpha3(), cc); } if (cc.getNumeric() != -1) { numericMap.put(cc.getNumeric(), cc); } } } private final String name; private final String alpha3; private final int numeric; private final Assignment assignment; private LDCountryCode(String name, String alpha3, int numeric, Assignment assignment) { this.name = name; this.alpha3 = alpha3; this.numeric = numeric; this.assignment = assignment; } /** * Get the country name. * * @return * The country name. */ public String getName() { return name; } /** * Get the ISO 3166-1 alpha-2 code. * * @return * The ISO 3166-1 alpha-2 code. */ public String getAlpha2() { return name(); } /** * Get the ISO 3166-1 alpha-3 code. * * @return * The ISO 3166-1 alpha-3 code. * Some country codes reserved exceptionally (such as {@link #EU}) * returns {@code null}. */ public String getAlpha3() { return alpha3; } /** * Get the ISO 3166-1 numeric code. * * @return * The ISO 3166-1 numeric code. * Country codes reserved exceptionally (such as {@link #EU}) * returns {@code -1}. */ public int getNumeric() { return numeric; } /** * Get the assignment state of this country code in ISO 3166-1. * * @return * The assignment state. * * @see Decoding table of ISO 3166-1 alpha-2 codes */ public Assignment getAssignment() { return assignment; } /** * Convert this {@code CountryCode} instance to a {@link Locale} instance. * *

* In most cases, this method creates a new {@code Locale} instance * every time it is called, but some {@code CountryCode} instances return * their corresponding entries in {@code Locale} class. For example, * {@link #CA CountryCode.CA} always returns {@link Locale#CANADA}. *

* *

* The table below lists {@code CountryCode} entries whose {@code toLocale()} * do not create new Locale instances but return entries in * {@code Locale} class. *

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
CountryCodeLocale
{@link LDCountryCode#CA CountryCode.CA}{@link Locale#CANADA}
{@link LDCountryCode#CN CountryCode.CN}{@link Locale#CHINA}
{@link LDCountryCode#DE CountryCode.DE}{@link Locale#GERMANY}
{@link LDCountryCode#FR CountryCode.FR}{@link Locale#FRANCE}
{@link LDCountryCode#GB CountryCode.GB}{@link Locale#UK}
{@link LDCountryCode#IT CountryCode.IT}{@link Locale#ITALY}
{@link LDCountryCode#JP CountryCode.JP}{@link Locale#JAPAN}
{@link LDCountryCode#KR CountryCode.KR}{@link Locale#KOREA}
{@link LDCountryCode#TW CountryCode.TW}{@link Locale#TAIWAN}
{@link LDCountryCode#US CountryCode.US}{@link Locale#US}
* * @return * A {@code Locale} instance that matches this {@code CountryCode}. */ public Locale toLocale() { return new Locale("", name()); } /** * Get the currency. * *

* This method is an alias of {@link Currency}{@code .}{@link * Currency#getInstance(Locale) getInstance}{@code (}{@link * #toLocale()}{@code )}. The only difference is that this method * returns {@code null} when {@code Currency.getInstance(Locale)} * throws {@code IllegalArgumentException}. *

* *

* This method returns {@code null} when the territory represented by * this {@code CountryCode} instance does not have a currency. * {@link #AQ} (Antarctica) is one example. *

* *

* In addition, this method returns {@code null} also when the ISO 3166 * code represented by this {@code CountryCode} instance is not * supported by the implementation of {@link * Currency#getInstance(Locale)}. At the time of this writing, * {@link #SS} (South Sudan) is one example. *

* * @return * A {@code Currency} instance. In some cases, null * is returned. * * @since 1.4 * * @see Currency#getInstance(Locale) */ public Currency getCurrency() { try { return Currency.getInstance(toLocale()); } catch (IllegalArgumentException e) { // Currency.getInstance(Locale) throws IllegalArgumentException // when the given ISO 3166 code is not supported. return null; } } /** * Get a {@code CountryCode} that corresponds to the given ISO 3166-1 * alpha-2 or * alpha-3 code. * *

* This method calls {@link #getByCode(String, boolean) getByCode}{@code (code, true)}. * Note that the behavior has changed since the version 1.13. In the older versions, * this method was an alias of {@code getByCode(code, false)}. *

* * @param code * An ISO 3166-1 alpha-2 or alpha-3 code. * * @return * A {@code CountryCode} instance, or {@code null} if not found. * * @see #getByCode(String, boolean) */ public static LDCountryCode getByCode(String code) { return getByCode(code, true); } /** * Get a {@code CountryCode} that corresponds to the given ISO 3166-1 * alpha-2 or * alpha-3 code. * *

* This method calls {@link #getByCode(String, boolean) getByCode}{@code (code, false)}. *

* * @param code * An ISO 3166-1 alpha-2 or alpha-3 code. * * @return * A {@code CountryCode} instance, or {@code null} if not found. * * @since 1.13 * * @see #getByCode(String, boolean) */ public static LDCountryCode getByCodeIgnoreCase(String code) { return getByCode(code, false); } /** * Get a {@code CountryCode} that corresponds to the given ISO 3166-1 * alpha-2 or * alpha-3 code. * * @param code * An ISO 3166-1 alpha-2 or alpha-3 code. * * @param caseSensitive * If {@code true}, the given code should consist of upper-case letters only. * If {@code false}, this method internally canonicalizes the given code by * {@link String#toUpperCase()} and then performs search. For example, * {@code getByCode("jp", true)} returns {@code null}, but on the other hand, * {@code getByCode("jp", false)} returns {@link #JP CountryCode.JP}. * * @return * A {@code CountryCode} instance, or {@code null} if not found. */ public static LDCountryCode getByCode(String code, boolean caseSensitive) { if (code == null) { return null; } switch (code.length()) { case 2: code = canonicalize(code, caseSensitive); return getByAlpha2Code(code); case 3: code = canonicalize(code, caseSensitive); return getByAlpha3Code(code); default: return null; } } /** * Get a {@code CountryCode} that corresponds to the country code of * the given {@link Locale} instance. * * @param locale * A {@code Locale} instance. * * @return * A {@code CountryCode} instance, or {@code null} if not found. * * @see Locale#getCountry() */ public static LDCountryCode getByLocale(Locale locale) { if (locale == null) { return null; } // Locale.getCountry() returns either an empty string or // an uppercase ISO 3166 2-letter code. return getByCode(locale.getCountry(), true); } /** * Canonicalize the given country code. * * @param code * ISO 3166-1 alpha-2 or alpha-3 country code. * * @param caseSensitive * {@code true} if the code should be handled case-sensitively. * * @return * If {@code code} is {@code null} or an empty string, * {@code null} is returned. * Otherwise, if {@code caseSensitive} is {@code true}, * {@code code} is returned as is. * Otherwise, {@code code.toUpperCase()} is returned. */ static String canonicalize(String code, boolean caseSensitive) { if (code == null || code.length() == 0) { return null; } if (caseSensitive) { return code; } else { return code.toUpperCase(); } } private static LDCountryCode getByAlpha2Code(String code) { try { return Enum.valueOf(LDCountryCode.class, code); } catch (IllegalArgumentException e) { return null; } } private static LDCountryCode getByAlpha3Code(String code) { return alpha3Map.get(code); } /** * Get a {@code CountryCode} that corresponds to the given * ISO 3166-1 * numeric code. * * @param code * An ISO 3166-1 numeric code. * * @return * A {@code CountryCode} instance, or {@code null} if not found. * If 0 or a negative value is given, {@code null} is returned. */ public static LDCountryCode getByCode(int code) { if (code <= 0) { return null; } return numericMap.get(code); } /** * Get a list of {@code CountryCode} by a name regular expression. * *

* This method is almost equivalent to {@link #findByName(Pattern) * findByName}{@code (Pattern.compile(regex))}. *

* * @param regex * Regular expression for names. * * @return * List of {@code CountryCode}. If nothing has matched, * an empty list is returned. * * @throws IllegalArgumentException * {@code regex} is {@code null}. * * @throws java.util.regex.PatternSyntaxException * {@code regex} failed to be compiled. * * @since 1.11 */ public static List findByName(String regex) { if (regex == null) { throw new IllegalArgumentException("regex is null."); } // Compile the regular expression. This may throw // java.util.regex.PatternSyntaxException. Pattern pattern = Pattern.compile(regex); return findByName(pattern); } /** * Get a list of {@code CountryCode} by a name pattern. * *

* For example, the list obtained by the code snippet below: *

* *
   * Pattern pattern = Pattern.compile(".*United.*");
   * List<CountryCode> list = CountryCode.findByName(pattern);
* *

* contains 6 {@code CountryCode}s as listed below. *

* *
    *
  1. {@link #AE} : United Arab Emirates *
  2. {@link #GB} : United Kingdom *
  3. {@link #TZ} : Tanzania, United Republic of *
  4. {@link #UK} : United Kingdom *
  5. {@link #UM} : United States Minor Outlying Islands *
  6. {@link #US} : United States *
* * @param pattern * Pattern to match names. * * @return * List of {@code CountryCode}. If nothing has matched, * an empty list is returned. * * @throws IllegalArgumentException * {@code pattern} is {@code null}. * * @since 1.11 */ public static List findByName(Pattern pattern) { if (pattern == null) { throw new IllegalArgumentException("pattern is null."); } List list = new ArrayList<>(); for (LDCountryCode entry : values()) { // If the name matches the given pattern. if (pattern.matcher(entry.getName()).matches()) { list.add(entry); } } return list; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy