public final class Resources extends Object
| Constructor and Description |
|---|
Resources(String theBaseName)
Constructor that builds a manager in default locale.
|
Resources(String theBaseName,
ClassLoader theClassLoader)
Constructor that builds a manager in default locale
using specified ClassLoader.
|
Resources(String theBaseName,
Locale theLocale)
Constructor that builds a manager in specified locale.
|
Resources(String theBaseName,
Locale theLocale,
ClassLoader theClassLoader)
Constructor that builds a manager in specified locale.
|
| Modifier and Type | Method and Description |
|---|---|
String |
format(String key,
Object[] args)
Retrieve a string from resource bundle and format it with specified arguments.
|
boolean |
getBoolean(String key)
Retrieve a boolean from bundle.
|
boolean |
getBoolean(String key,
boolean defaultValue)
Retrieve a boolean from bundle.
|
ResourceBundle |
getBundle()
Retrieve underlying ResourceBundle.
|
byte |
getByte(String key)
Retrieve a byte from bundle.
|
byte |
getByte(String key,
byte defaultValue)
Retrieve a byte from bundle.
|
char |
getChar(String key)
Retrieve a char from bundle.
|
char |
getChar(String key,
char defaultValue)
Retrieve a char from bundle.
|
Date |
getDate(String key)
Retrieve a date from bundle.
|
Date |
getDate(String key,
Date defaultValue)
Retrieve a date from bundle.
|
Date |
getDateTime(String key)
Retrieve a date + time from bundle.
|
Date |
getDateTime(String key,
Date defaultValue)
Retrieve a time from bundle.
|
double |
getDouble(String key)
Retrieve a double from bundle.
|
double |
getDouble(String key,
double defaultValue)
Retrieve a double from bundle.
|
float |
getFloat(String key)
Retrieve a float from bundle.
|
float |
getFloat(String key,
float defaultValue)
Retrieve a float from bundle.
|
int |
getInteger(String key)
Retrieve a integer from bundle.
|
int |
getInteger(String key,
int defaultValue)
Retrieve a integer from bundle.
|
long |
getLong(String key)
Retrieve a long from bundle.
|
long |
getLong(String key,
long defaultValue)
Retrieve a long from bundle.
|
short |
getShort(String key)
Retrieve a short from bundle.
|
short |
getShort(String key,
short defaultValue)
Retrieve a short from bundle.
|
String |
getString(String key)
Retrieve a raw string from bundle.
|
String |
getString(String key,
Object arg1)
Retrieve a string from resource bundle and format it with specified arguments.
|
String |
getString(String key,
Object arg1,
Object arg2)
Retrieve a string from resource bundle and format it with specified arguments.
|
String |
getString(String key,
Object arg1,
Object arg2,
Object arg3)
Retrieve a string from resource bundle and format it with specified arguments.
|
String |
getString(String key,
Object arg1,
Object arg2,
Object arg3,
Object arg4)
Retrieve a string from resource bundle and format it with specified arguments.
|
Date |
getTime(String key)
Retrieve a time from bundle.
|
Date |
getTime(String key,
Date defaultValue)
Retrieve a time from bundle.
|
Resources |
withFailOnError(boolean failOnError)
Whether an exception should be thrown in case of an unknown resource or
not.
|
public Resources(String theBaseName)
theBaseName - the base name of ResourceBundlepublic Resources(String theBaseName, ClassLoader theClassLoader)
theBaseName - the base name of ResourceBundletheClassLoader - the classLoader to load ResourceBundle frompublic Resources(String theBaseName, Locale theLocale)
theBaseName - the base name of ResourceBundletheLocale - the Locale for resource bundlepublic Resources(String theBaseName, Locale theLocale, ClassLoader theClassLoader)
theBaseName - the base name of ResourceBundletheLocale - the Locale for resource bundletheClassLoader - the classLoader to load ResourceBundle frompublic Resources withFailOnError(boolean failOnError)
failOnError - true if an exception should be thrown
in case of an unknown resource, else falsepublic boolean getBoolean(String key, boolean defaultValue) throws MissingResourceException
key - the key of resourcedefaultValue - the default value if key is missingMissingResourceException - if a resource wasn't foundpublic boolean getBoolean(String key) throws MissingResourceException
key - the key of resourceMissingResourceException - if a resource wasn't foundpublic byte getByte(String key, byte defaultValue) throws MissingResourceException
key - the key of resourcedefaultValue - the default value if key is missingMissingResourceException - if a resource wasn't foundpublic byte getByte(String key) throws MissingResourceException
key - the key of resourceMissingResourceException - if a resource wasn't foundpublic char getChar(String key, char defaultValue) throws MissingResourceException
key - the key of resourcedefaultValue - the default value if key is missingMissingResourceException - if a resource wasn't foundpublic char getChar(String key) throws MissingResourceException
key - the key of resourceMissingResourceException - if a resource wasn't foundpublic short getShort(String key, short defaultValue) throws MissingResourceException
key - the key of resourcedefaultValue - the default value if key is missingMissingResourceException - if a resource wasn't foundpublic short getShort(String key) throws MissingResourceException
key - the key of resourceMissingResourceException - if a resource wasn't foundpublic int getInteger(String key, int defaultValue) throws MissingResourceException
key - the key of resourcedefaultValue - the default value if key is missingMissingResourceException - if a resource wasn't foundpublic int getInteger(String key) throws MissingResourceException
key - the key of resourceMissingResourceException - if a resource wasn't foundpublic long getLong(String key, long defaultValue) throws MissingResourceException
key - the key of resourcedefaultValue - the default value if key is missingMissingResourceException - if a resource wasn't foundpublic long getLong(String key) throws MissingResourceException
key - the key of resourceMissingResourceException - if a resource wasn't foundpublic float getFloat(String key, float defaultValue) throws MissingResourceException
key - the key of resourcedefaultValue - the default value if key is missingMissingResourceException - if a resource wasn't foundpublic float getFloat(String key) throws MissingResourceException
key - the key of resourceMissingResourceException - if a resource wasn't foundpublic double getDouble(String key, double defaultValue) throws MissingResourceException
key - the key of resourcedefaultValue - the default value if key is missingMissingResourceException - if a resource wasn't foundpublic double getDouble(String key) throws MissingResourceException
key - the key of resourceMissingResourceException - if a resource wasn't foundpublic Date getDate(String key, Date defaultValue) throws MissingResourceException
key - the key of resourcedefaultValue - the default value if key is missingMissingResourceException - if a resource wasn't foundpublic Date getDate(String key) throws MissingResourceException
key - the key of resourceMissingResourceException - if a resource wasn't foundpublic Date getTime(String key, Date defaultValue) throws MissingResourceException
key - the key of resourcedefaultValue - the default value if key is missingMissingResourceException - if a resource wasn't foundpublic Date getTime(String key) throws MissingResourceException
key - the key of resourceMissingResourceException - if a resource wasn't foundpublic Date getDateTime(String key, Date defaultValue) throws MissingResourceException
key - the key of resourcedefaultValue - the default value if key is missingMissingResourceException - if a resource wasn't foundpublic Date getDateTime(String key) throws MissingResourceException
key - the key of resourceMissingResourceException - if a resource wasn't foundpublic String getString(String key) throws MissingResourceException
key - the key of resourceMissingResourceException - if a resource wasn't foundpublic String getString(String key, Object arg1)
key - the key for resourcearg1 - an argumentpublic String getString(String key, Object arg1, Object arg2)
key - the key for resourcearg1 - an argumentarg2 - an argumentpublic String getString(String key, Object arg1, Object arg2, Object arg3)
key - the key for resourcearg1 - an argumentarg2 - an argumentarg3 - an argumentpublic String getString(String key, Object arg1, Object arg2, Object arg3, Object arg4)
key - the key for resourcearg1 - an argumentarg2 - an argumentarg3 - an argumentarg4 - an argumentpublic String format(String key, Object[] args) throws MissingResourceException
key - the key for resourceargs - an array of argumentsMissingResourceException - if withFailOnError(boolean) is true and the requested resource wasn't foundwithFailOnError(boolean)public ResourceBundle getBundle() throws MissingResourceException
MissingResourceException - if an error occursCopyright © 2005–2020. All rights reserved.