Package org.opensextant.data
Class Country
java.lang.Object
org.opensextant.data.GeoBase
org.opensextant.data.Place
org.opensextant.data.Country
Country metadata provided on this class includes:
- ISO-3166 country code 2-char and 3-char forms, aligned with US standard FIPS 10-4 codes
- Country aliases: nick names, variant names, abbreviations
- Affiliated territories
- Timezone and UTC offset for temporal calculations
- Primary and Secondary languages
- Author:
- Marc C. Ubaldino, MITRE, ubaldino at mitre dot org
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionFIPS 10-4 2-character country codeISO 2-character country codeISO 3-character country codeboolean
Fields inherited from class org.opensextant.data.Place
admin1, admin1Name, admin2, admin2Name, adminName, country, country_id, method, name_type
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Country is also known as some list of aliasesvoid
addLanguage
(String langid) When adding languages, please add the primary language FIRST.void
Country is also known as some list of aliasesvoid
addTerritory
(Country terr) void
addTimezone
(String label, double utcOffset) Add a timezone and its offset.void
Refactor -- use JodaTime and the TZDB more formally.boolean
containsDSTOffset
(double offset) boolean
boolean
containsUTCOffset
(double offset) Test if this Country contains the UTC offset.A full list/map of all timezone labels mapped to UTC offsets present in this country.Return name normalized, e.g., lowercase, w/out diacritics.Certain island nations, areas, and territories that have ISO country codes may not have a language.List the territories for this country.Return the full list of TZ.boolean
boolean
boolean
isPrimaryLanguage
(String langid) boolean
boolean
Territory ownership is defined only by the data fed to this API; We do not make any political statements here.void
setUniqueName
(boolean b) toString()
Generic label -- anything more sophisticated needs attention E.g.Methods inherited from class org.opensextant.data.Place
compareTo, copyTo, defaultHierarchicalPath, getAdmin1, getAdmin1Name, getAdmin1PostalCode, getAdmin2, getAdmin2Name, getAdminName, getConfidence, getCountry, getCountryCode, getFeatureClass, getFeatureCode, getFeatureDesignation, getHierarchicalPath, getId_bias, getInstanceId, getMethod, getName_bias, getName_type, getNDNamenorm, getPlaceID, getPlaceName, getPlacePostalCode, getPopulation, getPrecision, getSource, isAbbreviation, isAdmin1, isAdministrative, isASCIIName, isCode, isCoordinate, isCountry, isName, isNationalCapital, isPlace, isPopulated, isPostal, isSame, isShortName, isSpot, isUpperAdmin, isUppercaseName, sameBoundary, setAdmin1, setAdmin1Name, setAdmin1PostalCode, setAdmin2, setAdmin2Name, setAdminName, setConfidence, setCountry, setCountryCode, setFeatureClass, setFeatureCode, setHierarchicalPath, setId_bias, setInstanceId, setMethod, setName_bias, setName_type, setPlaceID, setPlaceName, setPlacePostalCode, setPopulation, setPrecision, setSource
Methods inherited from class org.opensextant.data.GeoBase
getGeohash, getKey, getLatitude, getLongitude, getName, hasCoordinate, setGeohash, setKey, setLatitude, setLatLon, setLongitude, setName
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.opensextant.data.Geocoding
hasCoordinate
Methods inherited from interface org.opensextant.data.LatLon
getLatitude, getLongitude, setLatitude, setLongitude
-
Field Details
-
CC_ISO2
ISO 2-character country code -
CC_ISO3
ISO 3-character country code -
CC_FIPS
FIPS 10-4 2-character country code -
isTerritory
public boolean isTerritory
-
-
Constructor Details
-
Country
A country abstraction that uses ISO 2-alpha as an ID, and any name given as the Place.name- Parameters:
iso2
- ISO 2-alpha code for this countrynm
- Country name
-
-
Method Details
-
getNamenorm
Return name normalized, e.g., lowercase, w/out diacritics. 's, etc.- Overrides:
getNamenorm
in classGeoBase
-
addAlias
Country is also known as some list of aliases- Parameters:
nm
- Country name/alias
-
getAliases
- Returns:
- set of aliases
-
addTimezone
Add a timezone and its offset. TZ labels vary, so variant labels are tracked as well. uppercase, lowercase- Parameters:
label
- TZ labelutcOffset
- floating point UTC offset in decimal hours. e.g., 7.5, -3.0 = (GMT-0300), etc.
-
addTimezone
Refactor -- use JodaTime and the TZDB more formally. For now, tzdb tracks the timezone metadata.- Parameters:
tz
- - Country.TZ object
-
containsTimezone
- Parameters:
tz
- any reasonable TZ label. Case-insensitive.- Returns:
- true if Country has this TZ
-
containsUTCOffset
public boolean containsUTCOffset(double offset) Test if this Country contains the UTC offset. Make sure you never pass a default of 0 (GMT+0) in, unless you really mean GMT0. No validation on your offset parameter is done.- Parameters:
offset
- UTC offset in hours. Valid values are -12.0 to 12.0- Returns:
- true if this Country contains the UTC offset.
-
containsDSTOffset
public boolean containsDSTOffset(double offset) -
addRegion
Country is also known as some list of aliases- Parameters:
regionid
- Region identifier or name.
-
getRegions
- Returns:
- set of regions in which this country belongs.
-
setUniqueName
public void setUniqueName(boolean b) -
hasUniqueName
public boolean hasUniqueName() -
toString
Description copied from class:GeoBase
Generic label -- anything more sophisticated needs attention E.g. to use Key + Name or just Key for a label would be very specific -
addLanguage
When adding languages, please add the primary language FIRST. Languages may be langID or langID+locale. TODO: add separate attributes for locales.- Parameters:
langid
- language
-
isSpoken
- Parameters:
langid
- language ID- Returns:
- if language (identified by ID l) is spoken
-
getPrimaryLanguage
Certain island nations, areas, and territories that have ISO country codes may not have a language.- Returns:
- first language in languages list (per addLanguage()); null if no languages present.
-
isPrimaryLanguage
- Parameters:
langid
- lang ID string- Returns:
- true if language given matches primary language
-
getLanguages
- Returns:
- collection of language IDs -- some may be unknown langIDs.
-
getAllTimezones
A full list/map of all timezone labels mapped to UTC offsets present in this country. Reference: geonames.org timezone table has timezones.txt; See our GeonamesUtility for how data is populated here on Country object.- Returns:
- map of TZ labels to UTC offsets.
-
getTZDatabase
Return the full list of TZ.- Returns:
- full list of TZ as hashmap
-
hasTerritories
public boolean hasTerritories() -
addTerritory
-
ownsTerritory
Territory ownership is defined only by the data fed to this API; We do not make any political statements here. You can change the underlying flat file data country-names-xxxx.csv anyway you want.- Parameters:
n
- name of country or territory- Returns:
- true if this country owns the named territory.
-
getTerritories
List the territories for this country. Returns an empty list if no territories associated.- Returns:
- list of Territories, that are Country objects flagged with isTerritory = true
-