java.util
Class ListResourceBundle

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.util.ResourceBundle sample code for java.util.ResourceBundle definition code for java.util.ResourceBundle 
      extended by java.util.ListResourceBundle
Direct Known Subclasses:
AccessibleResourceBundle sample code for javax.accessibility.AccessibleResourceBundle definition code for javax.accessibility.AccessibleResourceBundle

public abstract class ListResourceBundle
extends ResourceBundle sample code for java.util.ResourceBundle definition code for java.util.ResourceBundle

ListResourceBundle is an 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 the key, which must be a String, and the second element is the value associated with that key.

The following example shows two members of a resource bundle family with the base name "MyResources". "MyResources" is the default member of the bundle family, and "MyResources_fr" is the French member. These members are based on ListResourceBundle (a related example shows how you can add a bundle to this family that's based on a properties file). The keys in this example are of the form "s1" etc. 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.

 
 public class MyResources extends ListResourceBundle {
     public Object[][] getContents() {
         return contents;
     }
     static final Object[][] contents = {
     // LOCALIZE THIS
         {"s1", "The disk \"{1}\" contains {0}."},  // MessageFormat pattern
         {"s2", "1"},                               // location of {0} in pattern
         {"s3", "My Disk"},                         // sample disk name
         {"s4", "no files"},                        // first ChoiceFormat choice
         {"s5", "one file"},                        // second ChoiceFormat choice
         {"s6", "{0,number} files"},                // third ChoiceFormat choice
         {"s7", "3 Mar 96"},                        // sample date
         {"s8", new Dimension(1,5)}                 // real object, not just string
     // END OF MATERIAL TO LOCALIZE
     };
 }

 public class MyResources_fr extends ListResourceBundle {
     public Object[][] getContents() {
         return contents;
     }
     static final Object[][] contents = {
     // LOCALIZE THIS
         {"s1", "Le disque \"{1}\" {0}."},          // MessageFormat pattern
         {"s2", "1"},                               // location of {0} in pattern
         {"s3", "Mon disque"},                      // sample disk name
         {"s4", "ne contient pas de fichiers"},     // first ChoiceFormat choice
         {"s5", "contient un fichier"},             // second ChoiceFormat choice
         {"s6", "contient {0,number} fichiers"},    // third ChoiceFormat choice
         {"s7", "3 mars 1996"},                     // sample date
         {"s8", new Dimension(1,3)}                 // real object, not just string
     // END OF MATERIAL TO LOCALIZE
     };
 }
 

Since:
JDK1.1
See Also:
ResourceBundle sample code for java.util.ResourceBundle definition code for java.util.ResourceBundle , PropertyResourceBundle sample code for java.util.PropertyResourceBundle definition code for java.util.PropertyResourceBundle

Field Summary
 
Fields inherited from class java.util.ResourceBundle sample code for java.util.ResourceBundle definition code for java.util.ResourceBundle
parent sample code for java.util.ResourceBundle.parent definition code for java.util.ResourceBundle.parent
 
Constructor Summary
ListResourceBundle sample code for java.util.ListResourceBundle.ListResourceBundle() definition code for java.util.ListResourceBundle.ListResourceBundle() ()
          Sole constructor.
 
Method Summary
protected abstract  Object sample code for java.lang.Object definition code for java.lang.Object [][] getContents sample code for java.util.ListResourceBundle.getContents() definition code for java.util.ListResourceBundle.getContents() ()
          See class description.
 Enumeration sample code for java.util.Enumeration definition code for java.util.Enumeration <String sample code for java.lang.String definition code for java.lang.String > getKeys sample code for java.util.ListResourceBundle.getKeys() definition code for java.util.ListResourceBundle.getKeys() ()
          Implementation of ResourceBundle.getKeys.
 Object sample code for java.lang.Object definition code for java.lang.Object handleGetObject sample code for java.util.ListResourceBundle.handleGetObject(java.lang.String) definition code for java.util.ListResourceBundle.handleGetObject(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  key)
          Gets an object for the given key from this resource bundle.
 
Methods inherited from class java.util.ResourceBundle sample code for java.util.ResourceBundle definition code for java.util.ResourceBundle
getBundle sample code for java.util.ResourceBundle.getBundle(java.lang.String) definition code for java.util.ResourceBundle.getBundle(java.lang.String) , getBundle sample code for java.util.ResourceBundle.getBundle(java.lang.String, java.util.Locale) definition code for java.util.ResourceBundle.getBundle(java.lang.String, java.util.Locale) , getBundle sample code for java.util.ResourceBundle.getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader) definition code for java.util.ResourceBundle.getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader) , getLocale sample code for java.util.ResourceBundle.getLocale() definition code for java.util.ResourceBundle.getLocale() , getObject sample code for java.util.ResourceBundle.getObject(java.lang.String) definition code for java.util.ResourceBundle.getObject(java.lang.String) , getString sample code for java.util.ResourceBundle.getString(java.lang.String) definition code for java.util.ResourceBundle.getString(java.lang.String) , getStringArray sample code for java.util.ResourceBundle.getStringArray(java.lang.String) definition code for java.util.ResourceBundle.getStringArray(java.lang.String) , setParent sample code for java.util.ResourceBundle.setParent(java.util.ResourceBundle) definition code for java.util.ResourceBundle.setParent(java.util.ResourceBundle)
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

ListResourceBundle sample code for java.util.ListResourceBundle() definition code for java.util.ListResourceBundle()

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

Method Detail

handleGetObject sample code for java.util.ListResourceBundle.handleGetObject(java.lang.String) definition code for java.util.ListResourceBundle.handleGetObject(java.lang.String)

public final Object sample code for java.lang.Object definition code for java.lang.Object  handleGetObject(String sample code for java.lang.String definition code for java.lang.String  key)
Description copied from class: ResourceBundle sample code for java.util.ResourceBundle.handleGetObject(java.lang.String) definition code for java.util.ResourceBundle.handleGetObject(java.lang.String)
Gets an object for the given key from this resource bundle. Returns null if this resource bundle does not contain an object for the given key.

Specified by:
handleGetObject sample code for java.util.ResourceBundle.handleGetObject(java.lang.String) definition code for java.util.ResourceBundle.handleGetObject(java.lang.String) in class ResourceBundle sample code for java.util.ResourceBundle definition code for java.util.ResourceBundle
Parameters:
key - the key for the desired object
Returns:
the object for the given key, or null

getKeys sample code for java.util.ListResourceBundle.getKeys() definition code for java.util.ListResourceBundle.getKeys()

public Enumeration sample code for java.util.Enumeration definition code for java.util.Enumeration <String sample code for java.lang.String definition code for java.lang.String > getKeys()
Implementation of ResourceBundle.getKeys.

Specified by:
getKeys sample code for java.util.ResourceBundle.getKeys() definition code for java.util.ResourceBundle.getKeys() in class ResourceBundle sample code for java.util.ResourceBundle definition code for java.util.ResourceBundle

getContents sample code for java.util.ListResourceBundle.getContents() definition code for java.util.ListResourceBundle.getContents()

protected abstract Object sample code for java.lang.Object definition code for java.lang.Object [][] getContents()
See class description.