Java Platform 1.2

java.util
Class ListResourceBundle

java.lang.Object
  |
  +--java.util.ResourceBundle
        |
        +--java.util.ListResourceBundle
Direct Known Subclasses:
AccessibleResourceBundle

public abstract class ListResourceBundle
extends ResourceBundle

ListResourceBundle is a abstract subclass of ResourceBundle that manages resources for a locale in a convenient and easy to use list. See ResourceBundle for more information about resource bundles in general.

Subclasses must override getContents and provide an array, where each item in the array is a pair of objects. The first element of each pair is a String key, and the second is the value associated with that key. [Right now, there's no error-checking code to enforce this, so you could specify key-value pairs that have something other than a String as a key. But since the interfaces are defined in terms of String, any value with a key that isn't a String will be inaccessible.]

In the following example, the keys are of the form "s1"... The actual keys are entirely up to your choice, so long as they are the same as the keys you use in your program to retrieve the objects from the bundle. Keys are case-sensitive. MyResource is the default version of the bundle family, and MyResource_fr is the french version:

 //====================
 class MyResource extends ListResourceBundle {
  public Object[][] getContents() {
      return contents;
  }
  static final Object[][] contents = {
  // LOCALIZE THIS
      {"s1", "3"},        // starting value in choice field
      {"s2", "MyDisk"},    // starting value in string field
      {"s3", "3 Mar 96"}, // starting value in date field
      {"s4", "The disk '{1}' contained {0} on {2}."}, // initial pattern
      {"s5", "0"},        // first choice number
      {"s6", "no files"}, // first choice value
      {"s7", "1"},        // second choice number
      {"s8", "one file"}, // second choice value
      {"s9", "2"},        // third choice number
      {"s10", "{0}|3 files"}, // third choice value
      {"s11", "format threw an exception: {0}"},  // generic exception message
      {"s12", "ERROR"},   // what to show in field in case of error
      {"s14", "Result"},  // label for formatted stuff
      {"s13", "Dialog"},  // standard font
      {"s15", "Pattern"}, // label for standard pattern
      {"s16", new Dimension(1,5)} // real object, not just string
  // END OF MATERIAL TO LOCALIZE
  };
 }
 //====================
 class MyResource_fr  extends ListResourceBundle {
  public Object[][] getContents() {
      return contents;
}
  static final Object[][] contents = {
  // LOCALIZE THIS
      {"s1", "3"},        // starting value in choice field
      {"s2", "MonDisk"},  // starting value in string field
      {"s3", "3 Mar 96"}, // starting value in date field
      {"s4", "Le disk '{1}' a {0} a {2}."},   // initial pattern
      {"s5", "0"},        // first choice number
      {"s6", "pas de files"}, // first choice value
      {"s7", "1"},        // second choice number
      {"s8", "une file"}, // second choice value
      {"s9", "2"},        // third choice number
      {"s10", "{0}|3 files"}, // third choice value
      {"s11", "Le format a jete une exception: {0}"}, // generic exception message
      {"s12", "ERROR"},   // what to show in field in case of error
      {"s14", "Resulte"}, // label for formatted stuff
      {"s13", "Dialogue"},    // standard font
      {"s15", "Pattern"}, // label for standard pattern
      {"s16", new Dimension(1,3)} // real object, not just string
  // END OF MATERIAL TO LOCALIZE
  };
 }
 

See Also:
ResourceBundle, PropertyResourceBundle

Fields inherited from class java.util.ResourceBundle
parent
 
Constructor Summary
ListResourceBundle()
          Sole constructor.
 
Method Summary
protected abstract  Object[][] getContents()
          See class description.
 Enumeration getKeys()
          Implementation of ResourceBundle.getKeys.
 Object handleGetObject(String key)
          Override of ResourceBundle, same semantics
 
Methods inherited from class java.util.ResourceBundle
getBundle, getBundle, getBundle, getLocale, getObject, getString, getStringArray, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListResourceBundle

public ListResourceBundle()
Sole constructor. (For invocation by subclass constructors, typically implicit.)
Method Detail

handleGetObject

public final Object handleGetObject(String key)
Override of ResourceBundle, same semantics
Overrides:
handleGetObject in class ResourceBundle

getKeys

public Enumeration getKeys()
Implementation of ResourceBundle.getKeys.
Overrides:
getKeys in class ResourceBundle

getContents

protected abstract Object[][] getContents()
See class description.

Java Platform 1.2

Submit a bug or feature Version 1.2 of Java Platform API Specification
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.