| java.lang.Object org.apache.commons.beanutils.locale.LocaleConvertUtilsBean
LocaleConvertUtilsBean | public class LocaleConvertUtilsBean (Code) | | 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:
- java.lang.BigDecimal
- java.lang.BigInteger
- byte and java.lang.Byte
- double and java.lang.Double
- float and java.lang.Float
- int and java.lang.Integer
- long and java.lang.Long
- short and java.lang.Short
- java.lang.String
- java.sql.Date
- java.sql.Time
- java.sql.Timestamp
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).
author: Yauheny Mikulski since: 1.7 |
Constructor Summary | |
public | LocaleConvertUtilsBean() Makes the state by default (deregisters all converters for all locales)
and then registers default locale converters. |
Method Summary | |
public String | convert(Object value) Convert the specified locale-sensitive value into a String. | public String | convert(Object value, String pattern) Convert the specified locale-sensitive value into a String
using the conversion pattern. | public String | convert(Object value, Locale locale, String pattern) Convert the specified locale-sensitive value into a String
using the paticular convertion pattern. | public Object | convert(String value, Class clazz) Convert the specified value to an object of the specified class (if
possible). | public 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. | public 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. | public 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. | public Object | convert(String[] values, Class clazz) Convert an array of specified values to an array of objects of the
specified class (if possible) . | public 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. | public void | deregister() Remove any registered
LocaleConverter . | public void | deregister(Locale locale) | public void | deregister(Class clazz, Locale locale) Remove any registered
LocaleConverter for the specified locale and Class. | public boolean | getApplyLocalized() | public Locale | getDefaultLocale() getter for defaultLocale. | public static LocaleConvertUtilsBean | getInstance() Gets singleton instance. | public 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 . | public void | register(LocaleConverter converter, Class clazz, Locale locale) Register a custom
LocaleConverter for the specified destination
Class , replacing any previously registered converter. | public void | setApplyLocalized(boolean newApplyLocalized) | public void | setDefaultLocale(Locale locale) setter for defaultLocale. |
LocaleConvertUtilsBean | public LocaleConvertUtilsBean()(Code) | | Makes the state by default (deregisters all converters for all locales)
and then registers default locale converters.
|
convert | public String convert(Object value, Locale locale, String pattern)(Code) | | Convert the specified locale-sensitive value into a String
using the paticular convertion pattern.
Parameters: value - The Value to be converted Parameters: locale - The locale Parameters: pattern - The convertion pattern the converted value throws: org.apache.commons.beanutils.ConversionException - if thrown by anunderlying Converter |
convert | public Object convert(String value, Class clazz)(Code) | | Convert the specified value to an object of the specified class (if
possible). Otherwise, return a String representation of the value.
Parameters: value - The String scalar value to be converted Parameters: clazz - The Data type to which this value should be converted. the converted value throws: org.apache.commons.beanutils.ConversionException - if thrown by anunderlying Converter |
convert | public Object convert(String value, Class clazz, String pattern)(Code) | | Convert the specified value to an object of the specified class (if
possible) using the convertion pattern. Otherwise, return a String
representation of the value.
Parameters: value - The String scalar value to be converted Parameters: clazz - The Data type to which this value should be converted. Parameters: pattern - The convertion pattern the converted value throws: org.apache.commons.beanutils.ConversionException - if thrown by anunderlying Converter |
convert | public Object convert(String value, Class clazz, Locale locale, String pattern)(Code) | | Convert the specified value to an object of the specified class (if
possible) using the convertion pattern. Otherwise, return a String
representation of the value.
Parameters: value - The String scalar value to be converted Parameters: clazz - The Data type to which this value should be converted. Parameters: locale - The locale Parameters: pattern - The convertion pattern the converted value throws: org.apache.commons.beanutils.ConversionException - if thrown by anunderlying Converter |
convert | public Object convert(String[] values, Class clazz, String pattern)(Code) | | Convert an array of specified values to an array of objects of the
specified class (if possible) using the convertion pattern.
Parameters: values - Value to be converted (may be null) Parameters: clazz - Java array or element class to be converted to Parameters: pattern - The convertion pattern the converted value throws: org.apache.commons.beanutils.ConversionException - if thrown by anunderlying Converter |
convert | public Object convert(String[] values, Class clazz)(Code) | | Convert an array of specified values to an array of objects of the
specified class (if possible) .
Parameters: values - Value to be converted (may be null) Parameters: clazz - Java array or element class to be converted to the converted value throws: org.apache.commons.beanutils.ConversionException - if thrown by anunderlying Converter |
convert | public Object convert(String[] values, Class clazz, Locale locale, String pattern)(Code) | | Convert an array of specified values to an array of objects of the
specified class (if possible) using the convertion pattern.
Parameters: values - Value to be converted (may be null) Parameters: clazz - Java array or element class to be converted to Parameters: locale - The locale Parameters: pattern - The convertion pattern the converted value throws: org.apache.commons.beanutils.ConversionException - if thrown by anunderlying Converter |
deregister | public void deregister(Locale locale)(Code) | | Remove any registered
LocaleConverter for the specified locale
Parameters: locale - The locale |
deregister | public void deregister(Class clazz, Locale locale)(Code) | | Remove any registered
LocaleConverter for the specified locale and Class.
Parameters: clazz - Class for which to remove a registered Converter Parameters: locale - The locale |
getApplyLocalized | public boolean getApplyLocalized()(Code) | | getter for applyLocalized
true if pattern is localized,otherwise false |
getDefaultLocale | public Locale getDefaultLocale()(Code) | | getter for defaultLocale.
the default locale |
lookup | public LocaleConverter lookup(Class clazz, Locale locale)(Code) | | Look up and return any registered
LocaleConverter for the specified
destination class and locale; if there is no registered Converter, return
null .
Parameters: clazz - Class for which to return a registered Converter Parameters: locale - The Locale The registered locale Converter, if any |
lookup | protected FastHashMap lookup(Locale locale)(Code) | | Look up and return any registered FastHashMap instance for the specified locale;
if there is no registered one, return null .
Parameters: locale - The Locale The FastHashMap instance contains the all LocaleConverter types forthe specified locale. |
register | public void register(LocaleConverter converter, Class clazz, Locale locale)(Code) | | Register a custom
LocaleConverter for the specified destination
Class , replacing any previously registered converter.
Parameters: converter - The LocaleConverter to be registered Parameters: clazz - The Destination class for conversions performed by thisConverter Parameters: locale - The locale |
setApplyLocalized | public void setApplyLocalized(boolean newApplyLocalized)(Code) | | setter for applyLocalized
Parameters: newApplyLocalized - true if pattern is localized,otherwise false |
setDefaultLocale | public void setDefaultLocale(Locale locale)(Code) | | setter for defaultLocale.
Parameters: locale - the default locale |
|
|