Class LocaleConvertUtilsBean
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).
- Since:
- 1.7
- 
Constructor SummaryConstructorsConstructorDescriptionMakes the state by default (deregisters all converters for all locales) and then registers default locale converters.
- 
Method SummaryModifier and TypeMethodDescriptionConvert the specified locale-sensitive value into a String.Convert the specified locale-sensitive value into a String using the conversion pattern.Convert the specified locale-sensitive value into a String using the particular conversion pattern.Convert an array of specified values to an array of objects of the specified class (if possible).<T> T[]Convert an array of specified values to an array of objects of the specified class (if possible) using the conversion pattern.<T> T[]Convert an array of specified values to an array of objects of the specified class (if possible) using the conversion pattern.Convert the specified value to an object of the specified class (if possible).Convert the specified value to an object of the specified class (if possible) using the conversion pattern.Convert the specified value to an object of the specified class (if possible) using the conversion pattern.protected Map<Class<?>, LocaleConverter<?>> Create allLocaleConvertertypes for specified locale.voidRemove any registeredLocaleConverter.voidderegister(Class<?> clazz, Locale locale) Remove any registeredLocaleConverterfor the specified locale and Class.voidderegister(Locale locale) Remove any registeredLocaleConverterfor the specified localebooleangetter for applyLocalizedgetter for defaultLocale.static LocaleConvertUtilsBeanGets singleton instance.<T> LocaleConverter<T> Look up and return any registeredLocaleConverterfor the specified destination class and locale; if there is no registered Converter, returnnull.protected Map<Class<?>, LocaleConverter<?>> Look up and return any registered map instance for the specified locale; if there is no registered one, returnnull.<T> voidregister(LocaleConverter<T> converter, Class<T> clazz, Locale locale) Register a customLocaleConverterfor the specified destinationClass, replacing any previously registered converter.voidsetApplyLocalized(boolean newApplyLocalized) setter for applyLocalizedvoidsetDefaultLocale(Locale locale) setter for defaultLocale.
- 
Constructor Details- 
LocaleConvertUtilsBeanpublic LocaleConvertUtilsBean()Makes the state by default (deregisters all converters for all locales) and then registers default locale converters.
 
- 
- 
Method Details- 
getInstanceGets singleton instance. This is the same as the instance used by the defaultLocaleBeanUtilsBeansingleton.- Returns:
- the singleton instance
 
- 
convertConvert the specified locale-sensitive value into a String.- Parameters:
- value- The Value to be converted
- Returns:
- the converted value
- Throws:
- ConversionException- if thrown by an underlying Converter
 
- 
convertConvert the specified locale-sensitive value into a String using the particular conversion pattern.- Parameters:
- value- The Value to be converted
- locale- The locale
- pattern- The conversion pattern
- Returns:
- the converted value
- Throws:
- ConversionException- if thrown by an underlying Converter
 
- 
convertConvert the specified locale-sensitive value into a String using the conversion pattern.- Parameters:
- value- The Value to be converted
- pattern- The conversion pattern
- Returns:
- the converted value
- Throws:
- ConversionException- if thrown by an underlying Converter
 
- 
convertConvert 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
- clazz- The Data type to which this value should be converted.
- Returns:
- the converted value
- Throws:
- ConversionException- if thrown by an underlying Converter
 
- 
convertConvert the specified value to an object of the specified class (if possible) using the conversion pattern. Otherwise, return a String representation of the value.- 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 conversion pattern
- Returns:
- the converted value
- Throws:
- ConversionException- if thrown by an underlying Converter
 
- 
convertConvert the specified value to an object of the specified class (if possible) using the conversion pattern. Otherwise, return a String representation of the value.- Parameters:
- value- The String scalar value to be converted
- clazz- The Data type to which this value should be converted.
- pattern- The conversion pattern
- Returns:
- the converted value
- Throws:
- ConversionException- if thrown by an underlying Converter
 
- 
convertConvert 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)
- clazz- Java array or element class to be converted to
- Returns:
- the converted value
- Throws:
- ConversionException- if thrown by an underlying Converter
 
- 
convertConvert an array of specified values to an array of objects of the specified class (if possible) using the conversion pattern.- Type Parameters:
- T- The result component type
- Parameters:
- values- Value to be converted (may be null)
- clazz- Java array or element class to be converted to
- locale- The locale
- pattern- The conversion pattern
- Returns:
- the converted value
- Throws:
- ConversionException- if thrown by an underlying Converter
 
- 
convertConvert an array of specified values to an array of objects of the specified class (if possible) using the conversion pattern.- Type Parameters:
- T- The array component type
- Parameters:
- values- Value to be converted (may be null)
- clazz- Java array or element class to be converted to
- pattern- The conversion pattern
- Returns:
- the converted value
- Throws:
- ConversionException- if thrown by an underlying Converter
 
- 
createCreate allLocaleConvertertypes for specified locale.- Parameters:
- locale- The Locale
- Returns:
- The map instance contains the all LocaleConvertertypes for the specified locale.
 
- 
deregisterRemove any registeredLocaleConverter.
- 
deregisterRemove any registeredLocaleConverterfor the specified locale and Class.- Parameters:
- clazz- Class for which to remove a registered Converter
- locale- The locale
 
- 
deregisterRemove any registeredLocaleConverterfor the specified locale- Parameters:
- locale- The locale
 
- 
getApplyLocalizedgetter for applyLocalized- Returns:
- trueif pattern is localized, otherwise- false
 
- 
getDefaultLocalegetter for defaultLocale.- Returns:
- the default locale
 
- 
lookupLook up and return any registeredLocaleConverterfor the specified destination class and locale; if there is no registered Converter, returnnull.- Type Parameters:
- T- The converter type.
- Parameters:
- clazz- Class for which to return a registered Converter
- locale- The Locale
- Returns:
- The registered locale Converter, if any
 
- 
lookupLook up and return any registered map instance for the specified locale; if there is no registered one, returnnull.- Parameters:
- locale- The Locale
- Returns:
- The map instance contains the all LocaleConvertertypes for the specified locale.
 
- 
registerRegister a customLocaleConverterfor the specified destinationClass, replacing any previously registered converter.- Type Parameters:
- T- The converter type.
- Parameters:
- converter- The LocaleConverter to be registered
- clazz- The Destination class for conversions performed by this Converter
- locale- The locale
 
- 
setApplyLocalizedsetter for applyLocalized- Parameters:
- newApplyLocalized-- trueif pattern is localized, otherwise- false
 
- 
setDefaultLocalesetter for defaultLocale.- Parameters:
- locale- the default locale
 
 
-