public class PropertyBundle
extends java.lang.Object
It is similar to java.util.ResourceBundle, but they differ as follows.
Maps.load(Map, InputStream)
to load the properties.
Thus, It is capable to handle UTF-16 and UTF-8 (but not ISO-8859-1).InputStream getResourceAsStream(String)
.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.
Modifier | Constructor and Description |
---|---|
protected |
PropertyBundle(java.lang.String baseName,
java.util.Locale locale,
Locator locator,
boolean caseInsensitive)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
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.
|
protected PropertyBundle(java.lang.String baseName, java.util.Locale locale, Locator locator, boolean caseInsensitive)
caseInsensitive
- whether the key used to access the map
is case-insensitive. If true, all keys are converted to lower cases.public static final PropertyBundle getBundle(java.lang.String baseName, java.util.Locale locale, Locator locator, boolean caseInsensitive)
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.public static final PropertyBundle getBundle(java.lang.String baseName, java.util.Locale locale, Locator locator)
public static final PropertyBundle getBundle(java.lang.String baseName, java.util.Locale locale, boolean caseInsensitive)
Locators.getDefault()
.caseInsensitive
- whether the key used to access the map
is case-insensitive. If true, all keys are converted to lower cases.public static final PropertyBundle getBundle(java.lang.String baseName, java.util.Locale locale)
Locators.getDefault()
.public final java.lang.String getProperty(java.lang.String key)
public final java.util.Map<java.lang.String,java.lang.String> getProperties()
public final java.util.Locale getLocale()
Copyright © 2005-2011 Potix Corporation. All Rights Reserved.