info.informatica.util.locale
Class LocalProperties

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<Object,Object>
          extended by java.util.Properties
              extended by info.informatica.util.locale.LocalProperties
All Implemented Interfaces:
Serializable, Cloneable, Map<Object,Object>

public final 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.

Version:
1.02
Author:
Carlos Amengual
See Also:
Serialized Form

Constructor Summary
LocalProperties(Locale locale)
          Creates a LocalProperties for the given locale.
LocalProperties(Locale locale, Properties p)
          Creates a LocalProperties.
 
Method Summary
static boolean check(String baseFileName, String ext)
          Checks if the default locale file with baseFileName exists an can be read.
 Locale getLocale()
          Gets the locale.
static LocalProperties loadBestLocalProperties(String baseName, String ext, Locale locale)
          Load the appropriate LocalProperties.
static LocalProperties loadLocalProperties(String baseName, String ext)
          Load the appropriate LocalProperties for the given basename and extension.
static LocalProperties loadLocalProperties(String baseName, String ext, Locale locale)
          Load the appropriate LocalProperties.
 
Methods inherited from class java.util.Properties
getProperty, getProperty, list, list, load, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, remove, size, toString, values
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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.

Parameters:
p - properties
Method Detail

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
Throws:
LocaleNotFoundException

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.
Throws:
LocaleNotFoundException

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.
Throws:
LocaleNotFoundException

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