|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.tonbeller.tbutils.res.Resources
Facade to access key/value pairs and application home directory.
Method Summary | |
void |
dump(Dumper d)
returns all key/value pairs for logging / debug |
void |
flush()
commits changes into the storage. |
boolean |
getBoolean(java.lang.String key)
looks up a boolean value |
double |
getDouble(java.lang.String key)
looks up a double value |
java.io.File |
getHomeDir()
returns the applications "home" directory which may contain properties files and other resources. |
int |
getInteger(java.lang.String key)
looks up an integervalue |
java.util.Locale |
getLocale()
returns the locale for this instance |
long |
getLong(java.lang.String key)
looks up a long value |
boolean |
getOptionalBoolean(java.lang.String key,
boolean defaultValue)
|
double |
getOptionalDouble(java.lang.String key,
double defaultValue)
|
int |
getOptionalInteger(java.lang.String key,
int defaultValue)
|
long |
getOptionalLong(java.lang.String key,
long defaultValue)
|
java.lang.String |
getOptionalString(java.lang.String key,
java.lang.String defaultValue)
looksup a string value. |
java.util.List |
getProviders()
returns the list of ResourceProvider 's that this instance
searches for properties. |
java.lang.String |
getString(java.lang.String key)
looks up a string value. |
java.lang.String |
getString(java.lang.String key,
java.lang.Object arg)
looks up a string value and formats via MessageFormat |
java.lang.String |
getString(java.lang.String key,
java.lang.Object[] args)
looks up a string value and formats via MessageFormat |
java.lang.String |
getString(java.lang.String key,
java.lang.Object arg0,
java.lang.Object arg1)
looks up a string value and formats via MessageFormat |
static Resources |
instance()
returns a Resources instance in the default locale
of the VM. |
static Resources |
instance(java.lang.Class clazz)
returns a Resources instance in the default locale.
|
static Resources |
instance(java.util.Locale browserLocale)
returns a Resources instance in the configured locale, or if
no locale was configured, in the browsers locale. |
static Resources |
instance(java.util.Locale browserLocale,
java.lang.Class clazz)
returns a Resources instance in the configured locale, or if
no locale was configured, in the browsers locale.
|
static Resources |
instance(java.util.Locale browserLocale,
java.lang.String bundleName)
returns a Resources instance in the configured locale, or if
no locale was configured, in the browsers locale.
|
java.util.Collection |
keySet()
returns a collection of all known keys. |
void |
removePersistent(java.lang.String key)
|
java.lang.String |
replace(java.lang.String s)
scans s for resource keys and replaces the keys by their values.
|
void |
setPersistentBoolean(java.lang.String key,
boolean value)
stores a key/value pair that will be persisted in the filesystem. |
void |
setPersistentDouble(java.lang.String key,
double value)
stores a key/value pair that will be persisted in the filesystem. |
void |
setPersistentInteger(java.lang.String key,
int value)
stores a key/value pair that will be persisted in the filesystem. |
void |
setPersistentLong(java.lang.String key,
long value)
stores a key/value pair that will be persisted in the filesystem. |
void |
setPersistentString(java.lang.String key,
java.lang.String value)
stores a key/value pair that will be persisted in the filesystem. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static Resources instance()
Resources
instance in the default locale
of the VM. This is NOT the locale of the users browser etc.
public static Resources instance(java.util.Locale browserLocale)
Resources
instance in the configured locale, or if
no locale was configured, in the browsers locale.
public static Resources instance(java.util.Locale browserLocale, java.lang.Class clazz)
Resources
instance in the configured locale, or if
no locale was configured, in the browsers locale.
If the package of clazz
contains a ResourceBundle named
resources.properties
that bundle will be added to the returned Resources
.
public static Resources instance(java.lang.Class clazz)
Resources
instance in the default locale.
If the package of clazz
contains a ResourceBundle named
resources.properties
that bundle will be added to the returned Resources
.
public static Resources instance(java.util.Locale browserLocale, java.lang.String bundleName)
Resources
instance in the configured locale, or if
no locale was configured, in the browsers locale.
The named ResourceBundle
will be added to the returned Resources
.
public java.lang.String getOptionalString(java.lang.String key, java.lang.String defaultValue)
key
- key in resourcebundledefaultValue
- returnvalue if key was not found
public java.lang.String getString(java.lang.String key) throws java.util.MissingResourceException
java.util.MissingResourceException
- if key was not foundpublic java.lang.String getString(java.lang.String key, java.lang.Object arg) throws java.util.MissingResourceException
java.util.MissingResourceException
public java.lang.String getString(java.lang.String key, java.lang.Object arg0, java.lang.Object arg1) throws java.util.MissingResourceException
java.util.MissingResourceException
public java.lang.String getString(java.lang.String key, java.lang.Object[] args) throws java.util.MissingResourceException
java.util.MissingResourceException
public boolean getBoolean(java.lang.String key) throws java.util.MissingResourceException
java.util.MissingResourceException
public boolean getOptionalBoolean(java.lang.String key, boolean defaultValue)
public int getInteger(java.lang.String key) throws java.util.MissingResourceException
java.util.MissingResourceException
public int getOptionalInteger(java.lang.String key, int defaultValue)
public long getLong(java.lang.String key) throws java.util.MissingResourceException
java.util.MissingResourceException
public long getOptionalLong(java.lang.String key, long defaultValue)
public double getDouble(java.lang.String key) throws java.util.MissingResourceException
java.util.MissingResourceException
public double getOptionalDouble(java.lang.String key, double defaultValue)
public java.util.Collection keySet()
public java.util.Locale getLocale()
public java.io.File getHomeDir()
public void setPersistentString(java.lang.String key, java.lang.String value)
flush()
public void setPersistentBoolean(java.lang.String key, boolean value)
flush()
public void setPersistentInteger(java.lang.String key, int value)
flush()
public void setPersistentLong(java.lang.String key, long value)
flush()
public void setPersistentDouble(java.lang.String key, double value)
flush()
public void removePersistent(java.lang.String key)
public void flush()
public void dump(Dumper d)
StringDumper
public java.lang.String replace(java.lang.String s)
s
for resource keys and replaces the keys by their values.
s
may contain resource keys in $-notation like ant, for example
${java.io.tmpdir}
.
If the property exists, its replaced by its value, e.g. /tmp
.
If the property does not exsist, the string is not changed, e.g. it remains
${java.io.tmpdir}
. A literal ${
is written as $${
(like ant), i.e. $${
is
replaced by ${
Example:
Resources res = Resources.instance(); String s = res.replace("${java.io.tmpdir}/mylogs"); // s = "c:\\temp/mylogs" for example File myLogs = new File(s);
Property values are replaced automatically, e.g. if the properties file contains
mylogs = ${java.io.tmpdir}/mylogsthen
Resources.instance().getString("mylogs")
will return "c:\\temp/mylogs".
public java.util.List getProviders()
ResourceProvider
's that this instance
searches for properties. The list may be modified.
ResourceProvider
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |