Package gov.nasa.arc.pds.tools.util
Class LocaleUtils
java.lang.Object
gov.nasa.arc.pds.tools.util.LocaleUtils
public class LocaleUtils extends Object
A helper class for Locale functionality and locale specific functionality.
This includes message retrieval and formatting from message bundles.
- Version:
- $Revision: $
- Author:
- jagander
-
Field Summary
Fields Modifier and Type Field Description ResourceBundlebundlestatic Map<Set<Object>,ResourceBundle>BUNDLE_CACHEstatic StringDEFAULT_BUNDLE_ROOTstatic booleanDEFAULT_DEV_MODEstatic StringDEFAULT_LANGUAGEstatic LocaleDEFAULT_LOCALEstatic StringDEFAULT_LOCALE_KEYstatic PatternLOCALE_PATTERNstatic StringNUMERIC_FORMAT -
Constructor Summary
Constructors Constructor Description LocaleUtils()LocaleUtils(Boolean devMode)LocaleUtils(String bundleRoot)LocaleUtils(Locale locale)LocaleUtils(Locale locale, Boolean devMode)LocaleUtils(Locale locale, Boolean devMode, String bundleRoot)LocaleUtils(Locale locale, Boolean devMode, ResourceBundle bundle)LocaleUtils(Locale locale, String bundleRoot)LocaleUtils(Locale locale, ResourceBundle bundle)LocaleUtils(ResourceBundle bundle) -
Method Summary
Modifier and Type Method Description StringformatBytes(double memory)StringformatBytes(double memory, Locale override)Format bytes to human readable textStringformatText(String message, Object... arguments)ResourceBundlegetBundle()LocalegetLocale()StringgetNumber(Number number)StringgetText(String key, Object... arguments)This retrieves a message from the appropriate properties file for your given Locale.booleanisDevMode()static booleanisValidLocale(Locale locale)static StringlocaleToString(Locale locale)protected voidsetBundle(ResourceBundle bundle)protected voidsetBundleName(String bundleName)protected voidsetDevMode(Boolean devMode)protected voidsetLocale(Locale locale)static LocalestringToLocale(String localeName)
-
Field Details
-
DEFAULT_LOCALE_KEY
- See Also:
- Constant Field Values
-
DEFAULT_LANGUAGE
- See Also:
- Constant Field Values
-
DEFAULT_LOCALE
-
DEFAULT_BUNDLE_ROOT
- See Also:
- Constant Field Values
-
DEFAULT_DEV_MODE
public static final boolean DEFAULT_DEV_MODE- See Also:
- Constant Field Values
-
bundle
-
LOCALE_PATTERN
-
NUMERIC_FORMAT
- See Also:
- Constant Field Values
-
BUNDLE_CACHE
-
-
Constructor Details
-
LocaleUtils
public LocaleUtils() -
LocaleUtils
-
LocaleUtils
-
LocaleUtils
-
LocaleUtils
-
LocaleUtils
-
LocaleUtils
-
LocaleUtils
-
LocaleUtils
-
LocaleUtils
-
-
Method Details
-
setLocale
-
getLocale
-
setDevMode
-
isDevMode
public boolean isDevMode() -
setBundle
-
getBundle
-
setBundleName
-
isValidLocale
-
stringToLocale
-
localeToString
-
getText
This retrieves a message from the appropriate properties file for your given Locale. It also uses any provided arguments to make substitutions and formatting changes to the found message. Note that this uses the OGNL expression language syntax for formatting.- Parameters:
key- - properties key used to look up messagearguments- - an array of arguments to be used in the message, uses OGNL syntax- Returns:
- found and formatted message
- Throws:
KeyNotFoundException
-
formatText
-
getNumber
-
formatBytes
-
formatBytes
Format bytes to human readable text- Parameters:
memory- The memory value to format.override- The locale to be used (determines decimal and grouping separators).- Returns:
- The formatted number string.
-