Class UTF8ResourceControl

java.lang.Object
java.util.ResourceBundle.Control
org.ka2ddo.util.UTF8ResourceControl

public class UTF8ResourceControl extends ResourceBundle.Control
This Control loads PropertyResourceBundles using a UTF-8 locale Reader to read the properties file.
Author:
Andrew Pavlin, KA2DDO
  • Field Details

  • Method Details

    • getFormats

      public List<String> getFormats(String baseName)
      Returns a List of Strings containing formats to be used to load resource bundles for the given baseName. The ResourceBundle.getBundle factory method tries to load resource bundles with formats in the order specified by the list. The list returned by this method must have at least one String. The predefined formats are "java.class" for class-based resource bundles and "java.properties" for properties-based ones. Strings starting with "java." are reserved for future extensions and must not be used by application-defined formats.
      Overrides:
      getFormats in class ResourceBundle.Control
      Parameters:
      baseName - the base name of the resource bundle, a fully qualified class name
      Returns:
      a List of Strings containing formats for loading resource bundles.
      Throws:
      NullPointerException - if baseName is null
      See Also:
    • newBundle

      public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IOException
      Instantiates a resource bundle for the given bundle name of the given format and locale, using the given class loader if necessary. This method returns null if there is no resource bundle available for the given parameters. If a resource bundle can't be instantiated due to an unexpected error, the error must be reported by throwing an Error or Exception rather than simply returning null.

      If the reload flag is true, it indicates that this method is being called because the previously loaded resource bundle has expired.

      This implementation instantiates a ResourceBundle as follows.

      Overrides:
      newBundle in class ResourceBundle.Control
      Parameters:
      baseName - the base bundle name of the resource bundle, a fully qualified class name
      locale - the locale for which the resource bundle should be instantiated
      format - the resource bundle format to be loaded
      loader - the ClassLoader to use to load the bundle
      reload - the flag to indicate bundle reloading; true if reloading an expired resource bundle, false otherwise
      Returns:
      the resource bundle instance, or null if none could be found.
      Throws:
      NullPointerException - if bundleName, locale, format, or loader is null, or if null is returned by toBundleName
      IllegalArgumentException - if format is unknown, or if the resource found for the given parameters contains malformed data.
      ClassCastException - if the loaded class cannot be cast to ResourceBundle
      ExceptionInInitializerError - if the initialization provoked by this method fails.
      SecurityException - If a security manager is present and creation of new instances is denied. See Class.newInstance() for details.
      IOException - if an error occurred when reading resources using any I/O operations