Golibri

org.golibri.iso
Class Alpha2CountryCodes

java.lang.Object
  extended byorg.golibri.iso.Alpha2CountryCodes

public final class Alpha2CountryCodes
extends java.lang.Object

The Alpha2CountryCodes class contains all alpha-2 country codes as specified by the ISO 3166 Standard. The class allows to create Alpha2CountryCode objects that are verified againsts the existing set of alpha-2 country codes in the ISO 3166 Standard. The full set of alpha-2 country codes can be found in the resource file org/golibri/iso/countrycodes.xml. This resource file can be found in the zip-file golibri-resources.zip which comes with each golibri distribution. If needed the XML-file can be updated or changed to serve your own needs. The Alpha2CountryCodes class is for working specifically with alpha-2 country codes. The preferred way to represent countries is with org.golibri.common.contact.Country.

See Also:
Alpha2CountryCode, Country

Constructor Summary
Alpha2CountryCodes()
           
 
Method Summary
static boolean exists(Alpha2CountryCode countryCode)
          Method to check whether an alpha-2 country code exists.
static boolean exists(java.lang.String countryCode)
          Method to check whether an alpha-2 country code exists.
static Alpha2CountryCode getCountryCode(java.lang.String countryCode)
          Factory method to create alpha-2 country code objects.
static Alpha2CountryCode[] getCountryCodes()
          Static method that returns all existing alpha-2 country codes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Alpha2CountryCodes

public Alpha2CountryCodes()
Method Detail

getCountryCode

public static Alpha2CountryCode getCountryCode(java.lang.String countryCode)
Factory method to create alpha-2 country code objects. Constructing a Alpha2CountryCode through this method also requires the country code to exist in the ISO 3166 Standard.

Parameters:
countryCode - String parameter containing the alpha-2 country code
Throws:
java.lang.NullPointerException - If the parameter countryCode is null
java.lang.IllegalArgumentException - If the parameter countryCode is not well-formatted or does not exist in the ISO 3166 Standard

getCountryCodes

public static Alpha2CountryCode[] getCountryCodes()
Static method that returns all existing alpha-2 country codes.

Returns:
an array of Alpha2CountryCode objects containing all existing alpha-2 country codes

exists

public static boolean exists(Alpha2CountryCode countryCode)
Method to check whether an alpha-2 country code exists. This method can be used to perform a check on Alpha2CountryCode objects that were not created with the factory method getCountryCode or when the origin of the objects is incertain.

Parameters:
countryCode - The alpha-2 country code that needs to be checked
Returns:
true if the country code exists, false otherwise

exists

public static boolean exists(java.lang.String countryCode)
Method to check whether an alpha-2 country code exists. This method can be be used to perform a check before getCountryCode() is called to avoid receiving an IllegalArgumentException.

Parameters:
countryCode - The country code that needs to be checked
Returns:
true if the country code exists, false otherwise

Golibri