public class Region extends Object implements Comparable<Region>
Region
is the class representing a Unicode Region Code, also known as a
Unicode Region Subtag, which is defined based upon the BCP 47 standard. We often think of
"regions" as "countries" when defining the characteristics of a locale. Region codes There are different
types of region codes that are important to distinguish.
Macroregion - A code for a "macro geographical (continental) region, geographical sub-region, or selected economic and other grouping" as defined in UN M.49 (http://unstats.un.org/unsd/methods/m49/m49regin.htm). These are typically 3-digit codes, but contain some 2-letter codes, such as the LDML code QO added for Outlying Oceania. Not all UNM.49 codes are defined in LDML, but most of them are. Macroregions are represented in ICU by one of three region types: WORLD ( region code 001 ), CONTINENTS ( regions contained directly by WORLD ), and SUBCONTINENTS ( things contained directly by a continent ).
TERRITORY - A Region that is not a Macroregion. These are typically codes for countries, but also include areas that are not separate countries, such as the code "AQ" for Antarctica or the code "HK" for Hong Kong (SAR China). Overseas dependencies of countries may or may not have separate codes. The codes are typically 2-letter codes aligned with the ISO 3166 standard, but BCP47 allows for the use of 3-digit codes in the future.
UNKNOWN - The code ZZ is defined by Unicode LDML for use to indicate that the Region is unknown, or that the value supplied as a region was invalid.
DEPRECATED - Region codes that have been defined in the past but are no longer in modern usage, usually due to a country splitting into multiple territories or changing its name.
GROUPING - A widely understood grouping of territories that has a well defined membership such that a region code has been assigned for it. Some of these are UNM.49 codes that do't fall into the world/continent/sub-continent hierarchy, while others are just well known groupings that have their own region code. Region "EU" (European Union) is one such region code that is a grouping. Groupings will never be returned by the getContainingRegion() API, since a different type of region ( WORLD, CONTINENT, or SUBCONTINENT ) will always be the containing region instead.
Modifier and Type | Class and Description |
---|---|
static class |
Region.RegionType
RegionType is an enumeration defining the different types of regions.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Region other) |
boolean |
contains(Region other) |
static Set<Region> |
getAvailable(Region.RegionType type)
Used to retrieve all available regions of a specific type.
|
Set<Region> |
getContainedRegions()
Used to determine the sub-regions that are contained within this region.
|
Set<Region> |
getContainedRegions(Region.RegionType type)
Used to determine all the regions that are contained within this region and that match the given type
|
Region |
getContainingRegion()
Used to determine the macroregion that geographically contains this region.
|
Region |
getContainingRegion(Region.RegionType type)
Used to determine the macroregion that geographically contains this region and that matches the given type.
|
static Region |
getInstance(int code)
Returns a Region using the given numeric code as defined by UNM.49
|
static Region |
getInstance(String id)
Returns a Region using the given region ID.
|
int |
getNumericCode()
Returns the numeric code for this region
|
List<Region> |
getPreferredValues() |
Region.RegionType |
getType()
Returns this region's type.
|
String |
toString()
Returns the string representation of this region
|
public static Region getInstance(String id)
id
- The id of the region to be retrieved.NullPointerException
- if the supplied id is null.IllegalArgumentException
- if the supplied ID cannot be canonicalized to a Region ID that is known by ICU.public static Region getInstance(int code)
code
- The numeric code of the region to be retrieved.IllegalArgumentException
- if the supplied numeric code is not recognized.public static Set<Region> getAvailable(Region.RegionType type)
type
- The type of regions to be returned ( TERRITORY, MACROREGION, etc. )public Region getContainingRegion()
public Region getContainingRegion(Region.RegionType type)
public Set<Region> getContainedRegions()
public Set<Region> getContainedRegions(Region.RegionType type)
public List<Region> getPreferredValues()
public boolean contains(Region other)
public String toString()
public int getNumericCode()
public Region.RegionType getType()
public int compareTo(Region other)
compareTo
in interface Comparable<Region>
Copyright © 2016 Unicode, Inc. and others.