Class LocalProperties

All Implemented Interfaces:
Serializable, Cloneable, Map<Object,Object>

public class LocalProperties extends Properties
Adds the notion of localization to the Properties class.

Allows property files to be loaded according to Locale information, and provides a getLocale method to retrieve the Locale corresponding to this LocalProperties object.

See Also:
  • Constructor Details

    • LocalProperties

      public LocalProperties(Locale locale)
      Creates a LocalProperties for the given locale.
      Parameters:
      locale - the locale
    • LocalProperties

      public LocalProperties(Locale locale, Properties p)
      Creates a LocalProperties with a default set of properties.
      Parameters:
      locale - the locale.
      p - properties
  • Method Details

    • getLocale

      public Locale getLocale()
      Gets the locale.
      Returns:
      the real locale name of this object, which may be different from the locale by which was invoked at the factory.
    • loadLocalProperties

      public static LocalProperties loadLocalProperties(String baseName, String ext) throws LocaleNotFoundException
      Load the appropriate LocalProperties for the given basename and extension.
      Parameters:
      baseName - the base name for the properties
      ext - the file extension
      Returns:
      the requested LocalProperties object, or the one for the default locale if the requested one could not be loaded.
      Throws:
      LocaleNotFoundException - if no LocalProperties could be loaded (this use of the exception is a bit bogus).
    • loadBestLocalProperties

      public static LocalProperties loadBestLocalProperties(String baseName, String ext, Locale locale) throws LocaleNotFoundException
      Load the appropriate LocalProperties.

      First tries to return the LocalProperties for the given locale, and if not possible, returns the default.

      Parameters:
      baseName - see class description.
      ext - the file extension
      locale - see class description.
      Returns:
      the requested LocalProperties object, or the one for the default locale if the requested one could not be loaded.
      Throws:
      LocaleNotFoundException - if no LocalProperties could be loaded (this use of the exception is a bit bogus).
    • loadLocalProperties

      public static LocalProperties loadLocalProperties(String baseName, String ext, Locale locale) throws LocaleNotFoundException
      Load the appropriate LocalProperties.
      Parameters:
      baseName - see class description.
      ext - the file extension
      locale - see class description.
      Returns:
      the requested LocalProperties object, or null if no properties could be loaded.
      Throws:
      LocaleNotFoundException - if the LocalProperties could not be loaded (this use of the exception is a bit bogus).
    • check

      public static boolean check(String baseFileName, String ext)
      Checks if the default locale file with baseFileName exists an can be read.
      Parameters:
      baseFileName - see class description.
      ext - the file extension
      Returns:
      true if the default locale exists, false otherwise