Class Country

  • All Implemented Interfaces:
    Geocoding, LatLon

    public class Country
    extends Place
    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
    Marc C. Ubaldino, MITRE, ubaldino at mitre dot org
    • Field Detail

      • CC_ISO2

        public java.lang.String CC_ISO2
        ISO 2-character country code
      • CC_ISO3

        public java.lang.String CC_ISO3
        ISO 3-character country code
      • CC_FIPS

        public java.lang.String CC_FIPS
        FIPS 10-4 2-character country code
      • isTerritory

        public boolean isTerritory
    • Constructor Detail

      • Country

        public Country​(java.lang.String iso2,
                       java.lang.String nm)
        A country abstraction that uses ISO 2-alpha as an ID, and any name given as the
        iso2 - ISO 2-alpha code for this country
        nm - Country name
    • Method Detail

      • getNamenorm

        public java.lang.String getNamenorm()
        Return name normalized, e.g., lowercase, w/out diacritics. 's, etc.
        getNamenorm in class GeoBase
      • addAlias

        public void addAlias​(java.lang.String nm)
        Country is also known as some list of aliases
        nm - Country name/alias
      • getAliases

        public java.util.Set<java.lang.String> getAliases()
        set of aliases
      • addTimezone

        public void addTimezone​(java.lang.String label,
                                double utcOffset)
        Add a timezone and its offset. TZ labels vary, so variant labels are tracked as well. uppercase, lowercase
        label - TZ label
        utcOffset - floating point UTC offset in decimal hours. e.g., 7.5, -3.0 = (GMT-0300), etc.
      • addTimezone

        public void addTimezone​(Country.TZ tz)
        Refactor -- use JodaTime and the TZDB more formally. For now, tzdb tracks the timezone metadata.
        tz - - Country.TZ object
      • containsTimezone

        public boolean containsTimezone​(java.lang.String tz)
        tz - any reasonable TZ label. Case-insensitive.
        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.
        offset - UTC offset in hours. Valid values are -12.0 to 12.0
        true if this Country contains the UTC offset.
      • containsDSTOffset

        public boolean containsDSTOffset​(double offset)
      • addRegion

        public void addRegion​(java.lang.String regionid)
        Country is also known as some list of aliases
        regionid - Region identifier or name.
      • getRegions

        public java.util.Set<java.lang.String> getRegions()
        set of regions in which this country belongs.
      • setUniqueName

        public void setUniqueName​(boolean b)
      • hasUniqueName

        public boolean hasUniqueName()
      • toString

        public java.lang.String 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
        toString in class Place
        string repr of the location
      • addLanguage

        public void addLanguage​(java.lang.String langid)
        When adding languages, please add the primary language FIRST. Languages may be langID or langID+locale. TODO: add separate attributes for locales.
        langid - language
      • isSpoken

        public boolean isSpoken​(java.lang.String langid)
        langid - language ID
        if language (identified by ID l) is spoken
      • getPrimaryLanguage

        public java.lang.String getPrimaryLanguage()
        Certain island nations, areas, and territories that have ISO country codes may not have a language.
        first language in languages list (per addLanguage()); null if no languages present.
      • isPrimaryLanguage

        public boolean isPrimaryLanguage​(java.lang.String langid)
        langid - lang ID string
        true if language given matches primary language
      • getLanguages

        public java.util.Collection<java.lang.String> getLanguages()
        collection of language IDs -- some may be unknown langIDs.
      • getAllTimezones

        public java.util.Map<java.lang.String,​java.lang.Double> getAllTimezones()
        A full list/map of all timezone labels mapped to UTC offsets present in this country. Reference: timezone table has timezones.txt; See our GeonamesUtility for how data is populated here on Country object.
        map of TZ labels to UTC offsets.
      • getTZDatabase

        public java.util.Map<java.lang.String,​Country.TZ> getTZDatabase()
        Return the full list of TZ.
        full list of TZ as hashmap
      • hasTerritories

        public boolean hasTerritories()
      • addTerritory

        public void addTerritory​(Country terr)
      • ownsTerritory

        public boolean ownsTerritory​(java.lang.String n)
        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.
        n - name of country or territory
        true if this country owns the named territory.
      • getTerritories

        public java.util.Collection<Country> getTerritories()
        List the territories for this country. Returns an empty list if no territories associated.
        list of Territories, that are Country objects flagged with isTerritory = true