|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.opensymphony.xwork.util.LocalizedTextUtil
public class LocalizedTextUtil
Provides support for localization in XWork. Resource bundles are searched in the following order:
Constructor Summary | |
---|---|
LocalizedTextUtil()
|
Method Summary | |
---|---|
static void |
addDefaultResourceBundle(java.lang.String resourceBundleName)
Add's the bundle to the internal list of default bundles. |
static void |
clearDefaultResourceBundles()
Clears the internal list of resource bundles. |
static java.lang.String |
findDefaultText(java.lang.String aTextName,
java.util.Locale locale)
Returns a localized message for the specified key, aTextName. |
static java.lang.String |
findDefaultText(java.lang.String aTextName,
java.util.Locale locale,
java.lang.Object[] params)
Returns a localized message for the specified key, aTextName, substituting variables from the array of params into the message. |
static java.util.ResourceBundle |
findResourceBundle(java.lang.String aBundleName,
java.util.Locale locale)
Finds the given resorce bundle by it's name. |
static java.lang.String |
findText(java.lang.Class aClass,
java.lang.String aTextName,
java.util.Locale locale)
Calls findText(Class aClass, String aTextName, Locale locale, String defaultMessage, Object[] args)
with aTextName as the default message. |
static java.lang.String |
findText(java.lang.Class aClass,
java.lang.String aTextName,
java.util.Locale locale,
java.lang.String defaultMessage,
java.lang.Object[] args)
Finds a localized text message for the given key, aTextName. |
static java.lang.String |
findText(java.lang.Class aClass,
java.lang.String aTextName,
java.util.Locale locale,
java.lang.String defaultMessage,
java.lang.Object[] args,
OgnlValueStack valueStack)
Finds a localized text message for the given key, aTextName. |
static java.lang.String |
findText(java.util.ResourceBundle bundle,
java.lang.String aTextName,
java.util.Locale locale)
Finds a localized text message for the given key, aTextName, in the specified resource bundle with aTextName as the default message. |
static java.lang.String |
findText(java.util.ResourceBundle bundle,
java.lang.String aTextName,
java.util.Locale locale,
java.lang.String defaultMessage,
java.lang.Object[] args)
Finds a localized text message for the given key, aTextName, in the specified resource bundle. |
static java.lang.String |
findText(java.util.ResourceBundle bundle,
java.lang.String aTextName,
java.util.Locale locale,
java.lang.String defaultMessage,
java.lang.Object[] args,
OgnlValueStack valueStack)
Finds a localized text message for the given key, aTextName, in the specified resource bundle. |
static java.util.Locale |
localeFromString(java.lang.String localeStr,
java.util.Locale defaultLocale)
Builds a Locale from a String of the form en_US_foo into a Locale
with language "en", country "US" and variant "foo". |
static void |
reset()
Clears all the internal lists. |
static void |
setReloadBundles(boolean reloadBundles)
Should resorce bundles be reloaded. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LocalizedTextUtil()
Method Detail |
---|
public static void clearDefaultResourceBundles()
public static void setReloadBundles(boolean reloadBundles)
webwork.i18n.reload
property.
reloadBundles
- reload bundles?public static void addDefaultResourceBundle(java.lang.String resourceBundleName)
resourceBundleName
- the name of the bundle to add.public static java.util.Locale localeFromString(java.lang.String localeStr, java.util.Locale defaultLocale)
Locale
from a String of the form en_US_foo into a Locale
with language "en", country "US" and variant "foo". This will parse the output of
Locale.toString()
.
localeStr
- The locale String to parse.defaultLocale
- The locale to use if localeStr is null.
public static java.lang.String findDefaultText(java.lang.String aTextName, java.util.Locale locale)
aTextName
- the message keylocale
- the locale the message should be for
public static java.lang.String findDefaultText(java.lang.String aTextName, java.util.Locale locale, java.lang.Object[] params)
aTextName
- the message keylocale
- the locale the message should be forparams
- an array of objects to be substituted into the message text
public static java.util.ResourceBundle findResourceBundle(java.lang.String aBundleName, java.util.Locale locale)
Thread.currentThread().getContextClassLoader()
as the classloader.
aBundleName
- the name of the bundle (usually it's FQN classname).locale
- the locale.
public static java.lang.String findText(java.lang.Class aClass, java.lang.String aTextName, java.util.Locale locale)
findText(Class aClass, String aTextName, Locale locale, String defaultMessage, Object[] args)
with aTextName as the default message.
findText(Class aClass, String aTextName, Locale locale, String defaultMessage, Object[] args)
public static java.lang.String findText(java.lang.Class aClass, java.lang.String aTextName, java.util.Locale locale, java.lang.String defaultMessage, java.lang.Object[] args)
ModelDriven
Action, then look for message in
the model's class hierarchy (repeat sub-steps listed above).${...}
will be treated as an OGNL expression and evaluated as such.
aClass
- the class whose name to use as the start point for the searchaTextName
- the key to find the text message forlocale
- the locale the message should be fordefaultMessage
- the message to be returned if no text message can be found in any
resource bundle
public static java.lang.String findText(java.lang.Class aClass, java.lang.String aTextName, java.util.Locale locale, java.lang.String defaultMessage, java.lang.Object[] args, OgnlValueStack valueStack)
ModelDriven
Action, then look for message in
the model's class hierarchy (repeat sub-steps listed above).${...}
will be treated as an OGNL expression and evaluated as such.
If a message is not found a WARN log will be logged.
aClass
- the class whose name to use as the start point for the searchaTextName
- the key to find the text message forlocale
- the locale the message should be fordefaultMessage
- the message to be returned if no text message can be found in any
resource bundlevalueStack
- the value stack to use to evaluate expressions instead of the
one in the ActionContext ThreadLocal
public static java.lang.String findText(java.util.ResourceBundle bundle, java.lang.String aTextName, java.util.Locale locale)
${...}
will be treated as an OGNL expression and evaluated as such.
findText(java.util.ResourceBundle, String, java.util.Locale, String, Object[])
public static java.lang.String findText(java.util.ResourceBundle bundle, java.lang.String aTextName, java.util.Locale locale, java.lang.String defaultMessage, java.lang.Object[] args)
${...}
will be treated as an OGNL expression and evaluated as such.
If a message is not found a WARN log will be logged.
bundle
- the bundleaTextName
- the keylocale
- the localedefaultMessage
- the default message to use if no message was found in the bundleargs
- arguments for the message formatter.public static java.lang.String findText(java.util.ResourceBundle bundle, java.lang.String aTextName, java.util.Locale locale, java.lang.String defaultMessage, java.lang.Object[] args, OgnlValueStack valueStack)
${...}
will be treated as an OGNL expression and evaluated as such.
If a message is not found a WARN log will be logged.
bundle
- the bundleaTextName
- the keylocale
- the localedefaultMessage
- the default message to use if no message was found in the bundleargs
- arguments for the message formatter.valueStack
- the OGNL value stack.public static void reset()
|
XWork Project Page | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |