org.zkoss.util.resource
Class PropertyBundle

java.lang.Object
  extended by org.zkoss.util.resource.PropertyBundle

public class PropertyBundle
extends java.lang.Object

The property bundle.

It is similar to java.util.ResourceBundle, but they differ as follows.

Instances of PropertyBundle are cached, so the performance is good. However, it implies the property file mapped by the giving class loader, name and locale is immutable. In other words, if you update the content of a property file, it might not be reflected to getString unless it is cleared out of the cache.

Thread safe.

Author:
tomyeh

Constructor Summary
protected PropertyBundle(java.lang.String baseName, java.util.Locale locale, Locator locator, boolean caseInsensitive)
          Constructor.
 
Method Summary
static PropertyBundle getBundle(java.lang.String baseName, java.util.Locale locale)
          Gets a resource bundle using the specified base name, locale, and the default locator, Locators.getDefault().
static PropertyBundle getBundle(java.lang.String baseName, java.util.Locale locale, boolean caseInsensitive)
          Gets a resource bundle using the specified base name, locale, and the default locator, Locators.getDefault().
static PropertyBundle getBundle(java.lang.String baseName, java.util.Locale locale, Locator locator)
          Gets a resource bundle using the specified base name, locale, and locator.
static PropertyBundle getBundle(java.lang.String baseName, java.util.Locale locale, Locator locator, boolean caseInsensitive)
          Gets a resource bundle using the specified base name, locale, and locator.
 java.util.Locale getLocale()
          Returns the locale of the bundle, or null if it is the default.
 java.util.Map<java.lang.String,java.lang.String> getProperties()
          Returns a map of all properties, (String key , String value).
 java.lang.String getProperty(java.lang.String key)
          Returns the property for the given key from this resource bundle or one of its parents.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyBundle

protected PropertyBundle(java.lang.String baseName,
                         java.util.Locale locale,
                         Locator locator,
                         boolean caseInsensitive)
Constructor.

Parameters:
caseInsensitive - whether the key used to access the map is case-insensitive. If true, all keys are converted to lower cases.
Method Detail

getBundle

public static final PropertyBundle getBundle(java.lang.String baseName,
                                             java.util.Locale locale,
                                             Locator locator,
                                             boolean caseInsensitive)
Gets a resource bundle using the specified base name, locale, and locator.

Parameters:
locator - the locator (never null). See Locators.getDefault().
caseInsensitive - whether the key used to access the map is case-insensitive. If true, all keys are converted to lower cases.
Returns:
the bundle; null if not found

getBundle

public static final PropertyBundle getBundle(java.lang.String baseName,
                                             java.util.Locale locale,
                                             Locator locator)
Gets a resource bundle using the specified base name, locale, and locator.


getBundle

public static final PropertyBundle getBundle(java.lang.String baseName,
                                             java.util.Locale locale,
                                             boolean caseInsensitive)
Gets a resource bundle using the specified base name, locale, and the default locator, Locators.getDefault().

Parameters:
caseInsensitive - whether the key used to access the map is case-insensitive. If true, all keys are converted to lower cases.
Returns:
the bundle; null if not found

getBundle

public static final PropertyBundle getBundle(java.lang.String baseName,
                                             java.util.Locale locale)
Gets a resource bundle using the specified base name, locale, and the default locator, Locators.getDefault().


getProperty

public final java.lang.String getProperty(java.lang.String key)
Returns the property for the given key from this resource bundle or one of its parents.


getProperties

public final java.util.Map<java.lang.String,java.lang.String> getProperties()
Returns a map of all properties, (String key , String value).


getLocale

public final java.util.Locale getLocale()
Returns the locale of the bundle, or null if it is the default. Note: it is value might not be the same as the locale being passed to the constructor, because the contructor will do some fallback.



Copyright © 2005-2011 Potix Corporation. All Rights Reserved. SourceForge.net Logo