Package ptolemy.util

Class OrderedResourceBundle


  • public class OrderedResourceBundle
    extends java.lang.Object
    Manage the resources for a locale using a set of static strings from a property file. See java.util.ResourceBundle for more information.

    Unlike other types of resource bundle, OrderedResourceBundle is not usually subclassed. Instead, the properties files containing the resource data are supplied. OrderedResourceBundle.getBundle will automatically look for the appropriate properties file and create an OrderedResourceBundle that refers to it. See java.util.ResourceBundle.getBundle() for a complete description of the search and instantiation strategy.

    Since:
    Ptolemy II 8.0
    Version:
    $Id$
    Author:
    Matthew Brooke
    • Constructor Summary

      Constructors 
      Constructor Description
      OrderedResourceBundle​(java.io.InputStream stream)
      Construct an OrderedResourceBundle.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static OrderedResourceBundle getBundle​(java.lang.String baseName)
      Get a resource bundle using the specified base name and the default locale.
      java.util.Iterator getKeys()
      Get an Iterator over the Set of keys, allowing retrieval of the keys in the original order as listed in the properties file.
      java.lang.String getString​(java.lang.String key)
      Get a string for the given key from this resource bundle.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • OrderedResourceBundle

        public OrderedResourceBundle​(java.io.InputStream stream)
                              throws java.io.IOException,
                                     java.lang.NullPointerException
        Construct an OrderedResourceBundle.
        Parameters:
        stream - InputStream for reading the java properties file from which this object will take its values. The stream is closed by this constructor.
        Throws:
        java.io.IOException - if there is a problem reading the InputStream
        java.lang.NullPointerException - if the InputStream is null
    • Method Detail

      • getBundle

        public static OrderedResourceBundle getBundle​(java.lang.String baseName)
                                               throws java.io.IOException,
                                                      java.util.MissingResourceException,
                                                      java.lang.NullPointerException
        Get a resource bundle using the specified base name and the default locale. The returned bundle has its entries in the same order as those in the original properties file, so a call to getKeys() will return an Iterator that allows retrieval of the keys in the original order. See javadoc for java.util.ResourceBundle for a complete description of the search and instantiation strategy.
        Parameters:
        baseName - String denoting the name of the properties file that will be read to populate this ResourceBundle.

        Example 1: if the baseName is MyPropsFile, and the default Locale is en_US, a properties file named: MyPropsFile_en_US.properties will be sought on the classpath.

        Example 2: if the baseName is org.mydomain.pkg.MyPropsFile, and the default Locale is en_US, a properties file named: org/mydomain/pkg/MyPropsFile_en_US.properties will be sought on the classpath.

        NOTE: valid comment chars are # and !

        valid delimiters are (space) : =
        Returns:
        OrderedResourceBundle - a ResourceBundle with its entries in the same order as those in the original properties file
        Throws:
        java.io.IOException - if there is a problem reading the file
        java.util.MissingResourceException - if the file cannot be found
        java.lang.NullPointerException - if baseName is null
      • getString

        public java.lang.String getString​(java.lang.String key)
        Get a string for the given key from this resource bundle.
        Parameters:
        key - the key for the desired string
        Returns:
        the string for the given key, or null if: a null value is actually mapped to this key, key not found, or key is null
      • getKeys

        public java.util.Iterator getKeys()
        Get an Iterator over the Set of keys, allowing retrieval of the keys in the original order as listed in the properties file.
        Returns:
        Iterator