org.apache.commons.beanutils.locale
public class LocaleConvertUtilsBean extends Object
Utility methods for converting locale-sensitive String scalar values to objects of the specified Class, String arrays to arrays of the specified Class and object to locale-sensitive String scalar value.
This class provides the implementations used by the static utility methods in LocaleConvertUtils.
The actual LocaleConverter instance to be used can be registered for each possible destination Class. Unless you override them, standard LocaleConverter instances are provided for all of the following destination Classes:
For backwards compatibility, the standard locale converters for primitive types (and the corresponding wrapper classes). If you prefer to have another LocaleConverter thrown instead, replace the standard LocaleConverter instances with ones created with the one of the appropriate constructors. It's important that LocaleConverter should be registered for the specified locale and Class (or primitive type).
Since: 1.7
Constructor Summary | |
---|---|
LocaleConvertUtilsBean()
Makes the state by default (deregisters all converters for all locales)
and then registers default locale converters. |
Method Summary | |
---|---|
String | convert(Object value)
Convert the specified locale-sensitive value into a String.
|
String | convert(Object value, String pattern)
Convert the specified locale-sensitive value into a String
using the conversion pattern.
|
String | convert(Object value, Locale locale, String pattern)
Convert the specified locale-sensitive value into a String
using the paticular convertion pattern.
|
Object | convert(String value, Class clazz)
Convert the specified value to an object of the specified class (if
possible). |
Object | convert(String value, Class clazz, String pattern)
Convert the specified value to an object of the specified class (if
possible) using the convertion pattern. |
Object | convert(String value, Class clazz, Locale locale, String pattern)
Convert the specified value to an object of the specified class (if
possible) using the convertion pattern. |
Object | convert(String[] values, Class clazz, String pattern)
Convert an array of specified values to an array of objects of the
specified class (if possible) using the convertion pattern.
|
Object | convert(String[] values, Class clazz)
Convert an array of specified values to an array of objects of the
specified class (if possible) .
|
Object | convert(String[] values, Class clazz, Locale locale, String pattern)
Convert an array of specified values to an array of objects of the
specified class (if possible) using the convertion pattern.
|
protected FastHashMap | create(Locale locale)
Create all LocaleConverter types for specified locale.
|
void | deregister()
Remove any registered LocaleConverter. |
void | deregister(Locale locale)
Remove any registered LocaleConverter for the specified locale
|
void | deregister(Class clazz, Locale locale)
Remove any registered LocaleConverter for the specified locale and Class.
|
boolean | getApplyLocalized()
getter for applyLocalized
|
Locale | getDefaultLocale()
getter for defaultLocale. |
static LocaleConvertUtilsBean | getInstance()
Gets singleton instance.
|
LocaleConverter | lookup(Class clazz, Locale locale)
Look up and return any registered LocaleConverter for the specified
destination class and locale; if there is no registered Converter, return
null .
|
protected FastHashMap | lookup(Locale locale)
Look up and return any registered FastHashMap instance for the specified locale;
if there is no registered one, return null .
|
void | register(LocaleConverter converter, Class clazz, Locale locale)
Register a custom LocaleConverter for the specified destination
Class , replacing any previously registered converter.
|
void | setApplyLocalized(boolean newApplyLocalized)
setter for applyLocalized
|
void | setDefaultLocale(Locale locale)
setter for defaultLocale. |
Parameters: value The Value to be converted
Returns: the converted value
Throws: org.apache.commons.beanutils.ConversionException if thrown by an underlying Converter
Parameters: value The Value to be converted pattern The convertion pattern
Returns: the converted value
Throws: org.apache.commons.beanutils.ConversionException if thrown by an underlying Converter
Parameters: value The Value to be converted locale The locale pattern The convertion pattern
Returns: the converted value
Throws: org.apache.commons.beanutils.ConversionException if thrown by an underlying Converter
Parameters: value The String scalar value to be converted clazz The Data type to which this value should be converted.
Returns: the converted value
Throws: org.apache.commons.beanutils.ConversionException if thrown by an underlying Converter
Parameters: value The String scalar value to be converted clazz The Data type to which this value should be converted. pattern The convertion pattern
Returns: the converted value
Throws: org.apache.commons.beanutils.ConversionException if thrown by an underlying Converter
Parameters: value The String scalar value to be converted clazz The Data type to which this value should be converted. locale The locale pattern The convertion pattern
Returns: the converted value
Throws: org.apache.commons.beanutils.ConversionException if thrown by an underlying Converter
Parameters: values Value to be converted (may be null) clazz Java array or element class to be converted to pattern The convertion pattern
Returns: the converted value
Throws: org.apache.commons.beanutils.ConversionException if thrown by an underlying Converter
Parameters: values Value to be converted (may be null) clazz Java array or element class to be converted to
Returns: the converted value
Throws: org.apache.commons.beanutils.ConversionException if thrown by an underlying Converter
Parameters: values Value to be converted (may be null) clazz Java array or element class to be converted to locale The locale pattern The convertion pattern
Returns: the converted value
Throws: org.apache.commons.beanutils.ConversionException if thrown by an underlying Converter
Deprecated: This method will be modified to return a Map in the next release.
Create all LocaleConverter types for specified locale.Parameters: locale The Locale
Returns: The FastHashMap instance contains the all LocaleConverter types for the specified locale.
Parameters: locale The locale
Parameters: clazz Class for which to remove a registered Converter locale The locale
Returns: true
if pattern is localized,
otherwise false
Returns: the default locale
Returns: the singleton instance
null
.
Parameters: clazz Class for which to return a registered Converter locale The Locale
Returns: The registered locale Converter, if any
Deprecated: This method will be modified to return a Map in the next release.
Look up and return any registered FastHashMap instance for the specified locale; if there is no registered one, returnnull
.
Parameters: locale The Locale
Returns: The FastHashMap instance contains the all LocaleConverter types for the specified locale.
Class
, replacing any previously registered converter.
Parameters: converter The LocaleConverter to be registered clazz The Destination class for conversions performed by this Converter locale The locale
Parameters: newApplyLocalized true
if pattern is localized,
otherwise false
Parameters: locale the default locale