The java.util.ListResourceBundle is a subclass of java.util.ResourceBundle.
It implements both handleGetObjects and getKeys for you.
The purpose of this bundle is to allow you to define localizable elements as a two-dimensional array of key-value pairs.
This bundle is easy to use and requires only minimal code, allowing for the focus to be on providing data in the bundle instead.
You can create your own ListResourceBundle by subclassing java.util.ListResourceBundle.
You must implement a single method, getContents(), which should return an array of key-value pairs.
The following code shows the structure of a simple bundle for the same example as above:
public class MyProgramResource extends ResourceBundle {
public Object getContents() {
return contents;
}
static Object[][] contents = {
{ "okKey", "ok" },
{ "cancelKey", "Cancel" },
}
}
The German version will look like :
public class MyProgramResource_de extends ResourceBundle {
public Object getContents() {
return contents;
}
static Object[][] contents = {
{ "okKey", "Gut"},
{"cancelKey", "Vernichten }
}
}
The UK version will look like :
public class MyProgramResource_uk extends ResourceBundle {
public Object getContents() {
return contents;
}
static Object[][] contents = {
{ "okKey", "ok" },
{ "cancelKey", "Dispose" },
}
}
ListResourceBundle can store any class of object and keys are always (quite obviously) a String object.
Sameer Tyagi is a Software Engineer with several years of programming experience in iNet application development and has conducted multiple training workshops in Java. Besides holding an Engineering degree in Electronics he is a Sun Certified Java 1.1 Programmer.
Email: sameertyagi@usa.net
JavaBytes
Internet Cyclone
This powerful, easy-to-use, internet optimizer is for
Windows 95, 98, ME, NT, 2000 and XP. It's designed to
automatically optimize your Windows settings, boosting your
Internet connection up to 200%.
Blackmail Applet
This applet prints out text that looks like letters cut out of a
newspaper. You can specify the text, the width and height of the
applet and the delay after each letter. Future versions will
have more parameters.
While surveys suggest that small businesses aren't prepared for ever-present security dangers, this Boston-area printer has maintained a pristine operation since a scare six years ago.