public class GeoRegion extends Object
Regions are strictly hierarchical, however the administrative units at some subdivision levels may be skipped. This situation can be found in Germany, for instance, where the subdivision level of "governmental districts" (orig. "Regierungsbezirke") is defined only in some of the "federal states" (orig. "Bundesländer").
StandardGeoRegions class and its inner classes.
Custom-defined region codes shall be compatible with these codes.
Locale, this class defines a default region.
The default region is set at class loading time from the "user.georegion" system property.
If the property is not defined or if its value is empty, a qualified guess of the default region is made from the default locale.
If the qualified guess fails, a GeoRegionException is thrown.
The default region can be changed at any time using the setDefault(GeoRegion) method.| Constructor and Description |
|---|
GeoRegion(String countryCode)
Creates a region for the given country code.
|
GeoRegion(String countryCode,
String level1SubdivisionCode)
Creates a region for the given country code and the codes at the 1st subdivision level.
|
GeoRegion(String countryCode,
String level1SubdivisionCode,
String level2SubdivisionCode)
Creates a region for the given country code and the codes at the 1st and 2nd subdivision levels.
|
GeoRegion(String countryCode,
String level1SubdivisionCode,
String level2SubdivisionCode,
String level3SubdivisionCode)
Creates a region for the given country code and the codes at the 1st to 3rd subdivision levels.
|
GeoRegion(String countryCode,
String level1SubdivisionCode,
String level2SubdivisionCode,
String level3SubdivisionCode,
String level4SubdivisionCode)
Creates a region for the given country code and the codes at the 1st to 4th subdivision levels.
|
GeoRegion(String countryCode,
String level1SubdivisionCode,
String level2SubdivisionCode,
String level3SubdivisionCode,
String level4SubdivisionCode,
String level5SubdivisionCode)
Creates a region for the given country code and the codes at the 1st to 5th subdivision levels.
|
| Modifier and Type | Method and Description |
|---|---|
GeoRegion |
atLevel(int level)
Returns this region limited to the given administrative level.
|
boolean |
equals(Object other) |
String |
getCode()
Return the overall code of this region.
|
String |
getCountryCode()
Return the country code of this region.
|
static GeoRegion |
getDefault()
Returns the default region.
|
GeoRegion |
getParent()
Returns the immediate parent of this region.
|
int |
hashCode() |
static GeoRegion |
parse(String code)
Returns a region corresponding to the given code.
|
static void |
setDefault(GeoRegion region)
Sets the default region.
|
String |
toString() |
public static final GeoRegion ROOT
public GeoRegion(String countryCode)
IllegalArgumentException - if countryCode is nullpublic GeoRegion(String countryCode, String level1SubdivisionCode)
IllegalArgumentException - if countryCode is nullIllegalArgumentException - if level1SubdivisionCode is nullpublic GeoRegion(String countryCode, String level1SubdivisionCode, String level2SubdivisionCode)
IllegalArgumentException - if countryCode is nullIllegalArgumentException - if level1SubdivisionCode is nullIllegalArgumentException - if level2SubdivisionCode is nullpublic GeoRegion(String countryCode, String level1SubdivisionCode, String level2SubdivisionCode, String level3SubdivisionCode)
IllegalArgumentException - if countryCode is nullIllegalArgumentException - if level1SubdivisionCode is nullIllegalArgumentException - if level2SubdivisionCode is nullIllegalArgumentException - if level3SubdivisionCode is nullpublic GeoRegion(String countryCode, String level1SubdivisionCode, String level2SubdivisionCode, String level3SubdivisionCode, String level4SubdivisionCode)
IllegalArgumentException - if countryCode is nullIllegalArgumentException - if level1SubdivisionCode is nullIllegalArgumentException - if level2SubdivisionCode is nullIllegalArgumentException - if level3SubdivisionCode is nullIllegalArgumentException - if level4SubdivisionCode is nullpublic GeoRegion(String countryCode, String level1SubdivisionCode, String level2SubdivisionCode, String level3SubdivisionCode, String level4SubdivisionCode, String level5SubdivisionCode)
IllegalArgumentException - if countryCode is nullIllegalArgumentException - if level1SubdivisionCode is nullIllegalArgumentException - if level2SubdivisionCode is nullIllegalArgumentException - if level3SubdivisionCode is nullIllegalArgumentException - if level4SubdivisionCode is nullIllegalArgumentException - if level5SubdivisionCode is nullpublic GeoRegion atLevel(int level)
IllegalArgumentException - if level is negativeIllegalArgumentException - if level is greater than 5public String getCode()
public String getCountryCode()
public static GeoRegion getDefault()
public GeoRegion getParent()
public static GeoRegion parse(String code)
IllegalArgumentException - if code is nullGeoRegionParseException - if the region code cannot be parsedpublic static void setDefault(GeoRegion region)