|
GeoSoft API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object | +--CountryManager
A country management singelton module. Useful for presentation of sorted list of countries in GUI like in country combo boxes etc.
The country manager instantiate country objects for the countries listed in the countries.txt resource of this package. The file lists ISO codes and the official english names for countries of the world. The countries.txt file has the following layout:
AF; AFGHANISTAN AL; ALBANIA DZ; ALGERIA AS; AMERICAN SAMOA AD; ANDORRA AO; ANGOLA :The country name is the defualt name used if a localized mapping is not found, or the client askes for countries independent of locale.
TODO: Connect to an online resource to pick country ISO codes.
For internal application usage, only ISO codes for countries should be used (i.e. for persistent storage store the ISO code rather than a country name).
In user interfaces, localized names should be used according to the locale of the application or preferred locale selected by the user. Localized names are maintained in resource bundles picked from property files with name Messages_xx_XX.properties where xx is the language specifier and XX is the country specifier. Provide localized country name mappings for all locales supported by the client application. The properties files should be located in the same package as the CountryManager. The properties files has the following format (Messages_en_US.properties):
AF = Afghanistan AL = Albania DZ = Algeria AS = American Samoa AD = Andorra AO = Angola :
Typical usage:
// Get a specific country Country country = CountryManager.getInstance().getCountry ("AF", french); // Get world countries localized to french (assuming // Messages_fr_FR.properties is available). Locale french = new Locale ("fr", "FR"); Collection countries = CountryManager.getInstance.getCountries (french); // Put countries (sorted according to locale) in a combo box TreeSet sorted = new TreeSet (countries); JComboBox countriesCombo = new JComboBox (new Vector (sorted));
Method Summary | |
Collection |
getCountries()
Return countries of the world (as specified in countries.txt) using the default (official ISO name) country names. |
Collection |
getCountries(Locale locale)
Return countries of the world (as specified in countries.txt) with names according to the specified locale. |
Country |
getCountry(String isoCode)
Get country for specified ISO code. |
Country |
getCountry(String isoCode,
Locale locale)
Get country for specified ISO code. |
static CountryManager |
getInstance()
Retur sole instance of this class. |
static void |
main(String[] args)
Testing the class. |
Methods inherited from class Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static CountryManager getInstance()
public Collection getCountries()
public Collection getCountries(Locale locale)
If the associated properties file is not found, the country names are set according to the default ISO standard.
locale
- Locale to setting country names.
public Country getCountry(String isoCode)
isoCode
- ISO code of country to find.
public Country getCountry(String isoCode, Locale locale)
isoCode
- ISO code of country to find.locale
- Locale to control name of requested country.
public static void main(String[] args)
args
- Not used.
|
GeoSoft API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |