Class TestRB

java.lang.Object
   |
   +----TestRB

public class TestRB
extends Object
The "A" in "WORA" stands for Anywhere, and Java came along when software was being created with one set of code for many locales, avoiding any hard-coded strings. Java goes a long way in advancing this concept.

The bulk of this class is just test code for the various aspects of internationalizing Java code: displaying localized user text, getting (parsing) and outputting (formatting) numbers and dates, and using a Collator and CollationKey[] to sort strings in localized fashion. The quickSort code is adapted from James Gosling's animated sort routine in the Sun sort demo. The different coding tasks follow IBM's Introduction to IBM Classes for Unicode tutorial.

There are no hard-coded strings here. All user prompts and displayed strings come from the resources package which consists of:

 package resources;
   class Res                     - English (default)
   class Res_en_GB               - English + UK
   class Res_fr                  - French
   class Res_fr_BE               - French + Belgium (sort of)
   class Res_es                  - Spanish
   class Res_es_AR               - Spanish + Argentina
   class Res_es_MX               - Spanish + Mexico
   class Res_da                  - Danish
 
So the easiest way to run the test code is to download the jar file and run it from the command line, as in: java -classpath %classpath%;.\TestRB.jar TestRB fr FR ECT [return] . If you find yourself translating the resources.Res class to a new language/country, I'd appreciate a copy of the finished product!

Version:
1.0 1999.05.02
Author:
Tony Dahlman

Variable Index

 o sep
Platform-dependent EOL string.

Constructor Index

 o TestRB()

Method Index

 o display(String)
A helper method to display strings to the console.
 o main(String[])
Test code.
 o quickSort(CollationKey[], int, int)
Do a quick sort on a CollationKey[] array.
 o swap(CollationKey[], int, int)
A boiler-plate swap method for CollationKey[] elements.

Variables

 o sep
 static String sep
Platform-dependent EOL string.

Constructors

 o TestRB
 public TestRB()

Methods

 o display
 public void display(String s)
A helper method to display strings to the console. It can be later switched to display the strings to a TextArea in an applet.

 o main
 public static void main(String args[])
Test code. With no arguments the default locale and time zone will be used. Supply language symbol (lower case) and country symbol (upper case) as two separate command line args to see this program run in other locales. You can supply a third argument, the Java TimeZone ID. For example, to look at the main() routine in the "fr FR" locale (France), the date dialog will use your usual TimeZone unless you specify "ECT" as the third arg.

 o quickSort
 void quickSort(CollationKey keys[],
                int lo0,
                int hi0)
Do a quick sort on a CollationKey[] array. Adapted from James Gosling's sort demo applet code, available from Javasoft . The code uses recursion and is fully(?) commented so you can (eventually) fathom how it works.

 o swap
 private void swap(CollationKey keys[],
                   int i,
                   int j)
A boiler-plate swap method for CollationKey[] elements.