Enum Class CountryCode
- All Implemented Interfaces:
Serializable,Comparable<CountryCode>,Constable
getName()), the
ISO 3166-1 alpha-3 code (getAlpha3()) and the
ISO 3166-1 numeric code (getNumeric()).
In addition, there are static methods to get a CountryCode instance that
corresponds to a given alpha-2/alpha-3/numeric code (getByCode(String), getByCode(int)).-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionÅland Islands [AX, ALA, 248, Officially assigned]Undefined [UNDEFINED, null, -1, User assigned] -
Method Summary
Modifier and TypeMethodDescriptionstatic List<CountryCode> findByName(String regex) Get a list ofCountryCodeby a name regular expression.static List<CountryCode> findByName(Pattern pattern) Get a list ofCountryCodeby a name pattern.static CountryCodegetByAlpha2Code(String code) static CountryCodegetByAlpha3Code(String code) static CountryCodegetByAlpha4Code(String code) Get aCountryCodethat corresponds to the given alpha-4 code.static CountryCodegetByCode(int code) static CountryCodestatic CountryCodestatic CountryCodegetByCodeIgnoreCase(String code) static CountryCodegetByLocale(Locale locale) Get aCountryCodethat corresponds to the country code of the givenLocaleinstance.Get the currency.getName()Get the country name.inttoLocale()Convert thisCountryCodeinstance to aLocaleinstance.static CountryCodeReturns the enum constant of this class with the specified name.static CountryCode[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
UNDEFINED
Undefined [UNDEFINED, null, -1, User assigned]This is not an official ISO 3166-1 code.
-
AC
-
AD
-
AE
-
AF
-
AG
-
AI
-
AL
-
AM
-
AN
-
AO
-
AQ
-
AR
-
AS
-
AT
-
AU
-
AW
-
AX
Åland Islands [AX, ALA, 248, Officially assigned]The country name was changed from "â„«land Islands" (up to 1.14) to "Ã…land Islands" (since 1.15).
-
AZ
-
BA
-
BB
-
BD
-
BE
-
BF
-
BG
-
BH
-
BI
-
BJ
-
BL
-
BM
-
BN
-
BO
-
BQ
-
BR
-
BS
-
BT
-
BU
-
BV
-
BW
-
BY
-
BZ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
-
TV
-
TW
-
TZ
-
UA
-
UG
-
UK
-
UM
-
US
-
UY
-
UZ
-
VA
-
VC
-
VE
-
VG
-
VI
-
VN
-
VU
-
WF
-
WS
-
XI
-
XU
-
XK
-
YE
-
YT
-
YU
-
ZA
-
ZM
-
ZR
-
ZW
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getByCode
-
getByCodeIgnoreCase
-
getByCode
-
getByLocale
Get aCountryCodethat corresponds to the country code of the givenLocaleinstance.- Parameters:
locale- ALocaleinstance.- Returns:
- A
CountryCodeinstance, ornullif not found. WhengetCountry()method of the givenLocaleinstance returnsnullor an empty string,CountryCode.UNDEFINEDis returned. - See Also:
-
getByAlpha2Code
-
getByAlpha3Code
-
getByAlpha4Code
Get aCountryCodethat corresponds to the given alpha-4 code.Recognized alpha-4 codes are listed in the table below.
- Parameters:
code- Alpha-4 code.- Returns:
- A
CountryCodeinstance, ornullif not found.
-
getByCode
-
findByName
Get a list ofCountryCodeby a name regular expression.This method is almost equivalent to
findByName(Pattern.compile(regex)).- Parameters:
regex- Regular expression for names.- Returns:
- List of
CountryCode. If nothing has matched, an empty list is returned. - Throws:
IllegalArgumentException-regexisnull.PatternSyntaxException-regexfailed to be compiled.
-
findByName
Get a list ofCountryCodeby 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
CountryCodes as listed below.- Parameters:
pattern- Pattern to match names.- Returns:
- List of
CountryCode. If nothing has matched, an empty list is returned. - Throws:
IllegalArgumentException-patternisnull.
-
getName
Get the country name.- Returns:
- The country name.
-
getAlpha2
-
getAlpha3
-
getNumeric
public int getNumeric() -
toLocale
Convert thisCountryCodeinstance to aLocaleinstance.In most cases, this method creates a new
Localeinstance every time it is called, but someCountryCodeinstances return their corresponding entries inLocaleclass. For example,CountryCode.CAalways returnsLocale.CANADA.The table below lists
CountryCodeentries whosetoLocale()do not create new Locale instances but return entries inLocaleclass.In addition,
toLocale()ofCountryCode.UNDEFINEDbehaves a bit differently. It returnsLocale.ROOTwhen it is available (i.e. when the version of Java SE is 1.6 or higher). Otherwise, it returns aLocaleinstance whose language and country are empty strings. Even in the latter case, the same instance is returned on every call.- Returns:
- A
Localeinstance that matches thisCountryCode.
-
getCurrency
Get the currency.This method is an alias of
Currency.getInstance(toLocale()). The only difference is that this method returnsnullwhenCurrency.getInstance(Locale)throwsIllegalArgumentException.This method returns
nullwhen the territory represented by thisCountryCodeinstance does not have a currency.AQ(Antarctica) is one example.In addition, this method returns
nullalso when the ISO 3166 code represented by thisCountryCodeinstance is not supported by the implementation ofCurrency.getInstance(Locale). At the time of this writing,SS(South Sudan) is one example.- Returns:
- A
Currencyinstance. In some cases, null is returned. - See Also:
-