Saturday, December 08, 2012

2012-12-08 Saturday - ISO 3166 Country Codes Utility Class


Last night I was looking for a small coding task that could be completed in an evening - that would allow me to add something of value to a personal utility library - and decided to work on a robust class to handle a variety of tasks related to ISO 3166 Country Codes.

[another one of my side projects is the implementation of a utility library of the United States Postal Service Pub 28 (Postal Addressing Standards) - of which this Country Code utility class will be of some re-use]

Two useful wikipedia.org page references:

The utility class I'm working on provides a number of functional capabilities:
  • Stores the following Country Code Information:
    • Short English Name
    • Two Character Alpha Code (Alpha-2)
    • Three Character Alpha Code (Alpha-3)
    • Three Character Numeric Code (Numeric-3)
    • Top Level Domain (TLD)
  • Stores the Country Code data in a multidimensional array for most of the primary functional processing 
  • Stores a Key-Value entry in a HashMap to allow searching by the Short Name, as well as by the following codes: Alpha-2, Alpha-3, Numeric-3, and TLD
  • Utility method to generate an XML structure of the primary array information
  • Utility method to generate HTML select snippets codes for  either Apha-2, Alpha-3, or Numeric-3 value codes.  A parameter allows the developer to specify which Country Code to set as the 'selected' value.  The method determines which type of code was passed via inspection of the characteristics of the single parameter.
  • Utility method to generate the XSD Enumerations for the Alpha-2, Alpha-3, and Numeric-3 Country Codes.
  • Utility method to dump the contents of a Country Code array
  • Utility method to dump the contents of a HashMap - which is searchable by all possible Key-Value combinations
  • Utility method to query the length of the array
  • Utility method to query the size of the HashMap

I've posted  files for the generated HTML select samples on github:gist
I've posted a github:gist file for the XML snippet of the enumerations:








No comments:

Copyright

© 2001-2021 International Technology Ventures, Inc., All Rights Reserved.