The Source for Java Technology Collaboration
User: Password:



Evan Summers's Blog

April 2008 Archives


Hello World Currencies

Posted by evanx on April 29, 2008 at 07:25 AM | Permalink | Comments (6)

Since i've hardly being doing anything very useful of late, i decided it's time to return to my potentially generally useful efforts of a year ago vis-a-vis "countries of the world" and publish something for a start, to prod myself into "completing" the task, which i was enjoying immensely before it was interrupted by some months of travel.

So i started preparing Java code which listed the world's countries, currencies, capitals, timezones, internet TLD's, dialing codes, et al, with the help of Wikipedia with its ISO listings. It was helluva interesting, especially the corner cases eg. terrorities which due to current and/or historical political events, are potentially on the borderline of being countries as opposed to um, eg. a defacto self-governing terrority of the secessionist variety, possibly recognised by the UN but not by some country who considers them still part of their territory - you get the picture!

Also interesting are various "quirks" eg. the currency for the British Virgin Islands is the US Dollar. Or an island where the southern part is a territory of France and the northern part is a territory of Holland.

Having compiled these lists, i should reconcile with Locale.getAvailableLocales() via ISO codes, and also the timezones of the capitals eg. reconciled with Java timezones via TimeZone. Also i need to update the country list eg. Kosovo declared independence, and it's status may have changed according to wikipedia?

I'll be publishing code on geo.dev.java.net under Apache License in due course, so you can cut and paste, slice and dice it! If you notice anything not quite right as we proceed, please lemme know, and we'll try to keep this thing correcto mundo, going forward.

Before i get onto the countries, here is teaser sample of the currencies...

putCurrency("AED", 2, "United Arab Emirates dirham");
putCurrency("AFN", 2, "Afghani");
putCurrency("ALL", 2, "Lek");
putCurrency("AMD", 2, "Armenian Dram");
putCurrency("ANG", 2, "Netherlands Antillian Guilder");
putCurrency("AOA", 2, "Kwanza");
putCurrency("ARS", 2, "Argentine Peso");
putCurrency("AUD", 2, "Australian Dollar");
putCurrency("AWG", 2, "Aruban Guilder");
putCurrency("AZN", 2, "Azerbaijanian Manat");
putCurrency("BAM", 2, "Convertible Marks");
putCurrency("BBD", 2, "Barbados Dollar");
putCurrency("BDT", 2, "Bangladeshi Taka");
putCurrency("BGN", 2, "Bulgarian Lev");
putCurrency("BHD", 3, "Bahraini Dinar");
putCurrency("BIF", 0, "Burundian Franc");
putCurrency("BMD", 2, "Bermudian Dollar");
putCurrency("BND", 2, "Brunei Dollar");
putCurrency("BOB", 2, "Boliviano");
putCurrency("BOV", 2, "Bolivian Mvdol (Funds code)");
putCurrency("BRL", 2, "Brazilian Real");
putCurrency("BSD", 2, "Bahamian Dollar");
putCurrency("BTN", 2, "Ngultrum");
putCurrency("BWP", 2, "Pula");
putCurrency("BYR", 0, "Belarussian Ruble");
putCurrency("BZD", 2, "Belize Dollar");
putCurrency("CAD", 2, "Canadian Dollar");
putCurrency("CDF", 2, "Franc Congolais");
putCurrency("CHE", 2, "WIR Euro (complementary currency)");
putCurrency("CHF", 2, "Swiss Franc");
putCurrency("CHW", 2, "WIR Franc (complementary currency)");
putCurrency("CLF", 0, "Unidades de formento (Funds code)");
putCurrency("CLP", 0, "Chilean Peso");
putCurrency("CNY", 2, "Yuan Renminbi");
putCurrency("COP", 2, "Colombian Peso");
putCurrency("COU", 2, "Unidad de Valor Real");
putCurrency("CRC", 2, "Costa Rican Colon");
putCurrency("CUP", 2, "Cuban Peso");
putCurrency("CVE", 2, "Cape Verde Escudo");
putCurrency("CYP", 2, "Cyprus Pound");
putCurrency("CZK", 2, "Czech Koruna");
putCurrency("DJF", 0, "Djibouti Franc");
putCurrency("DKK", 2, "Danish Krone");
putCurrency("DOP", 2, "Dominican Peso");
putCurrency("DZD", 2, "Algerian Dinar");
putCurrency("EEK", 2, "Kroon");
putCurrency("EGP", 2, "Egyptian Pound");
putCurrency("ERN", 2, "Nakfa");
putCurrency("ETB", 2, "Ethiopian Birr");
putCurrency("EUR", 2, "Euro");
putCurrency("FJD", 2, "Fiji Dollar");
putCurrency("FKP", 2, "Falkland Islands Pound");
putCurrency("GBP", 2, "Pound Sterling");
putCurrency("GEL", 2, "Lari");
putCurrency("GHC", 2, "Cedi");
putCurrency("GIP", 2, "Gibraltar pound");
putCurrency("GMD", 2, "Dalasi");
putCurrency("GNF", 0, "Guinea Franc");
putCurrency("GTQ", 2, "Quetzal");
putCurrency("GYD", 2, "Guyana Dollar");
putCurrency("HKD", 2, "Hong Kong Dollar");
putCurrency("HNL", 2, "Lempira");
putCurrency("HRK", 2, "Croatian Kuna");
putCurrency("HTG", 2, "Haiti Gourde");
putCurrency("HUF", 2, "Forint");
putCurrency("IDR", 2, "Rupiah");
putCurrency("ILS", 2, "New Israeli Shekel");
putCurrency("INR", 2, "Indian Rupee");
putCurrency("IQD", 3, "Iraqi Dinar");
putCurrency("IRR", 2, "Iranian Rial");
putCurrency("ISK", 0, "Iceland Krona");
putCurrency("JMD", 2, "Jamaican Dollar");
putCurrency("JOD", 3, "Jordanian Dinar");
putCurrency("JPY", 0, "Japanese yen");
putCurrency("KES", 2, "Kenyan Shilling");
putCurrency("KGS", 2, "Som");
putCurrency("KHR", 2, "Riel");
putCurrency("KMF", 0, "Comoro Franc");
putCurrency("KPW", 2, "North Korean Won");
putCurrency("KRW", 0, "South Korean Won");
putCurrency("KWD", 3, "Kuwaiti Dinar");
putCurrency("KYD", 2, "Cayman Islands Dollar");
putCurrency("KZT", 2, "Tenge");
putCurrency("LAK", 2, "Kip");
putCurrency("LBP", 2, "Lebanese Pound");
putCurrency("LKR", 2, "Sri Lanka Rupee");
putCurrency("LRD", 2, "Liberian Dollar");
putCurrency("LSL", 2, "Loti");
putCurrency("LTL", 2, "Lithuanian Litas");
putCurrency("LVL", 2, "Latvian Lats");
putCurrency("LYD", 3, "Libyan Dinar");
putCurrency("MAD", 2, "Moroccan Dirham");
putCurrency("MDL", 2, "Moldovan Leu");
putCurrency("MGA", 0, "Malagasy Ariary");
putCurrency("MKD", 2, "Denar");
putCurrency("MMK", 2, "Kyat");
putCurrency("MNT", 2, "Tugrik");
putCurrency("MOP", 2, "Pataca");
putCurrency("MRO", 2, "Ouguiya");
putCurrency("MTL", 2, "Maltese Lira");
putCurrency("MUR", 2, "Mauritius Rupee");
putCurrency("MVR", 2, "Rufiyaa");
putCurrency("MWK", 2, "Kwacha");
putCurrency("MXN", 2, "Mexican Peso");
putCurrency("MXV", 2, "Mexican Unidad de Inversion (UDI) (Funds code)");
putCurrency("MYR", 2, "Malaysian Ringgit");
putCurrency("MZN", 2, "Metical");
putCurrency("NAD", 2, "Namibian Dollar");
putCurrency("NGN", 2, "Naira");
putCurrency("NIO", 2, "Cordoba Oro");
putCurrency("NOK", 2, "Norwegian Krone");
putCurrency("NPR", 2, "Nepalese Rupee");
putCurrency("NZD", 2, "New Zealand Dollar");
putCurrency("OMR", 3, "Rial Omani");
putCurrency("PAB", 2, "Balboa");
putCurrency("PEN", 2, "Nuevo Sol");
putCurrency("PGK", 2, "Kina");
putCurrency("PHP", 2, "Philippine Peso");
putCurrency("PKR", 2, "Pakistan Rupee");
putCurrency("PLN", 2, "Zloty");
putCurrency("PYG", 0, "Guarani");
putCurrency("QAR", 2, "Qatari Rial");
putCurrency("ROL", 2, "Romanian Leu");
putCurrency("RON", 2, "Romanian New Leu");
putCurrency("RSD", 2, "Serbian Dinar");
putCurrency("RUB", 2, "Russian Ruble");
putCurrency("RWF", 0, "Rwanda Franc");
putCurrency("SAR", 2, "Saudi Riyal");
putCurrency("SBD", 2, "Solomon Islands Dollar");
putCurrency("SCR", 2, "Seychelles Rupee");
putCurrency("SDD", 2, "Sudanese Dinar");
putCurrency("SDG", 2, "Sudanese Pound");
putCurrency("SEK", 2, "Swedish Krona");
putCurrency("SGD", 2, "Singapore Dollar");
putCurrency("SHP", 2, "Saint Helena Pound");
putCurrency("SKK", 2, "Slovak Koruna");
putCurrency("SLL", 2, "Leone");
putCurrency("SOS", 2, "Somali Shilling");
putCurrency("SRD", 2, "Surinam Dollar");
putCurrency("STD", 2, "Dobra");
putCurrency("SYP", 2, "Syrian Pound");
putCurrency("SZL", 2, "Lilangeni");
putCurrency("THB", 2, "Baht");
putCurrency("TJS", 2, "Somoni");
putCurrency("TMM", 2, "Manat");
putCurrency("TND", 3, "Tunisian Dinar");
putCurrency("TOP", 2, "Pa'anga");
putCurrency("TRY", 2, "New Turkish Lira");
putCurrency("TTD", 2, "Trinidad and Tobago Dollar");
putCurrency("TWD", 2, "New Taiwan Dollar");
putCurrency("TZS", 2, "Tanzanian Shilling");
putCurrency("UAH", 2, "Hryvnia");
putCurrency("UGX", 2, "Uganda Shilling");
putCurrency("USD", 2, "US Dollar");
putCurrency("UYU", 2, "Peso Uruguayo");
putCurrency("UZS", 2, "Uzbekistan Som");
putCurrency("VEB", 2, "Venezuelan bolívar");
putCurrency("VND", 2, "Vietnamese đồng");
putCurrency("VUV", 0, "Vatu");
putCurrency("WST", 2, "Samoan Tala");
putCurrency("XAF", 0, "CFA Franc BEAC");
putCurrency("XCD", 2, "East Caribbean Dollar");
putCurrency("XOF", 0, "CFA Franc BCEAO");
putCurrency("XPF", 0, "CFP franc");
putCurrency("YER", 2, "Yemeni Rial");
putCurrency("ZAR", 2, "South African Rand");
putCurrency("ZMK", 2, "Kwacha");
putCurrency("ZWD", 2, "Zimbabwe Dollar");

where we specify the number of decimals.

Now to countries, with their currencies, languages, dialing codes, TLDs, and their capitals, with their coordinates, timezones and what-not, all cross-referenced via ISO codes! Baby steps... :)

First Class Java: Thoughts on a dot notation

Posted by evanx on April 05, 2008 at 05:03 AM | Permalink | Comments (13)

So last week i started rambling about "First Class Java." Lemme continue while i wait for my clothes to dry on the line outside, whilst i prepare myself for a wedding this afternoon, which i love, especially the eating and drinking and chatting and laughing and dancing part of it.

So i was wondering what notation would be neat for first-class references to properties, methods and fields, for this so-called "First Class Java" exercise.

Since we have .class notation for Class eg. Person.class, my first thought was to have something similar eg. .property, .field, .method - waddayathink?!

For example, let's say our Person.class has a property username. Then we could refer to its PropertyDescriptor as Person.username.property. We might also refer to it's Field and accessor Method as Person.username.field and Person.getUsername.method.

monkey1-200.png Comrades here have been touting using a hash (which is quite neat) eg. Person#getUsername (for first-class method referencing), and we see things like Person->username for properties. The question is then what non-conflicting notation for fields!?

(As an amusing side bar on hash notation, many years ago i was hosting two decidedly non-techie friends from London, and roped them into a geeky Linux User Group year-end dinner party. They got thoroughly bored, their heads down with all this technobabble going around and over their heads. The only time i saw them whip their heads up was when they heard the word "hash." Disappointingly for them, not the type they could converse about, but rather further technospeak related to unix scripts, which caused a further shoulder-drop. Heh heh.)

Back to the beef. Besides the hash and -> notations, for closures we see a => notation being bandied about willy-nilly. Urrrrgh!

The problem is that firstly, i personally dislike with a revulsion that is impossible to put into words adequately, such double-dastardly punctuation symbols like C/C++'s hideous ->, and => is even worse! Having said that, i don't mind C/C++'s &, and of course we all love it's dot notation for referencing.

Given that we have too many first-class thingymajigs like properties, methods, fields, and given that Java's preference in general is words rather than punctuation, eg. extends rather than C++'s doubly-distastful colons, i say using words like .method is better, and inline with Java's existing "dot-word notation" for meta-majiggies ie. .class.

In general, less char's is not better. (Where by "char's" i mean "characters," as a case in point.) Java takes the approach of readability over brevity, eg. lastKnownWhereabouts over lstKnwnWhabs, and extends rather than colons. (Lemme not launch into a whole tirade about unixen /usr and /tmp, and the elitist-obscuritism to which i am philosophically and psychotically indisposed.)

Given the above, a related point on the subject of closures is, sure, introduce closures if it's gonna simplify and robustify our libraries, API's and programs. But let's continue Java's legacy of beautiful readability rather than introducing the dastardliness of C++'s duplicitious punctiliousness.

Enough semantic monkeying around from me - please restore some sense and sensibility to this posting with your affably obliging comments - thank you very much! :)



Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds