Package gov.nasa.arc.pds.tools.util
Class LocaleUtils
java.lang.Object
gov.nasa.arc.pds.tools.util.LocaleUtils
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 -
Constructor Summary
ConstructorsConstructorDescriptionLocaleUtils(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 TypeMethodDescriptionformatBytes(double memory) formatBytes(double memory, Locale override) Format bytes to human readable textformatText(String message, Object... arguments) This retrieves a message from the appropriate properties file for your given Locale.booleanstatic booleanisValidLocale(Locale locale) static StringlocaleToString(Locale locale) protected voidsetBundle(ResourceBundle bundle) protected voidsetBundleName(String bundleName) protected voidsetDevMode(Boolean devMode) protected voidstatic LocalestringToLocale(String localeName)
-
Field Details
-
DEFAULT_LOCALE_KEY
- See Also:
-
DEFAULT_LANGUAGE
- See Also:
-
DEFAULT_LOCALE
-
DEFAULT_BUNDLE_ROOT
- See Also:
-
DEFAULT_DEV_MODE
public static final boolean DEFAULT_DEV_MODE- See Also:
-
bundle
-
LOCALE_PATTERN
-
NUMERIC_FORMAT
- See Also:
-
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
-
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.
-