The Source for Java Technology Collaboration
User: Password:



Evan Summers's Blog

Evan Summers Evan Summers studied mechanical engineering for 8 years, but still didn't know which way to turn a screw driver. So he tinkered with Java, and eventually found "that Swing." Now he lives in a shelter for Swing code junkies, and works on aptframework.dev.java.net.



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! :)

First Class Java: Call of Duty 4

Posted by evanx on March 25, 2008 at 04:24 AM | Permalink | Comments (16)

So i had this vague idea some weeks ago for some blog articles to keep myself amused if no one else. The idea is... to dream of a Java Refined. Not something totally different like JavaFX Script, or Scala et al, but some kind of evolution of the Java language that would be dreamy with a dollop of double-thick cream on top...

So i started making a list of things i would want, which went something like: first class properties; first class meta stuff like methods (FCM), fields and what-not; better annotations; better generics; structured literal data (eg. XML) and queries and what-not in the language; first-class handling of externalised data like localisable text and customisable what-nots.

rustic-school2-crop.jpg What is the point of this exercise you ask? To have something to think about and doodle about when i'm in my favourite coffee shop, and a topic to blog and converse about like now. Now i can't remember all of my wishlist exactly because i left it at home and i'm quite literally a thousand miles from home at the moment...

Anyways, i remember that when i looked at my list, i thought, what i want is "first class" this that and the other. So i thought lemme call this exercise "First Class Java."

But enough about me, what about you - how would you evolve the Java language? I'll collate all ya all's ideas, mind-meld them into some kinda concensus of me, myself and you, and write them up in some ongoing fashion for further consideration and discussion, just for the hell of it...

Having said that, if i win the lottery, i'll sponsor a team to create a slightly new, very Java'esque language with Netbeans support et al. To be honest, first i would buy myself a few first-class houses, sports cars, jets, yachts, etcetera, then after i've bought all that, i'll sponsor some first-class schools and clinics and what-not in my country (hey i also wanna help Obama make the world a better place), and then after that, i'll sponsor First Class Java with the petty change. Heh heh.

May 2008
Sun Mon Tue Wed Thu Fri Sat
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31


Search this blog:
  

Categories
Community: Java Enterprise
Community: Java Tools
Community: Java Web Services and XML
Community: JavaDesktop
Community: linux.java.net
Community: NetBeans
Open Source
Archives

April 2008
March 2008
January 2008
November 2007
October 2007
September 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006

Recent Entries

Hello World Currencies

First Class Java: Thoughts on a dot notation

First Class Java: Call of Duty 4



Powered by
Movable Type 3.01D


 Feed java.net RSS Feeds