Class LocaleConvertUtils
- java.lang.Object
-
- org.apache.commons.beanutils.locale.LocaleConvertUtils
-
public class LocaleConvertUtils extends java.lang.ObjectUtility 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.
The implementations for these method are provided by
LocaleConvertUtilsBean. These static utility method use the default instance. More sophisticated can be provided by using aLocaleConvertUtilsBeaninstance.
-
-
Constructor Summary
Constructors Constructor Description LocaleConvertUtils()Deprecated.Will be private in 2.0.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.lang.Stringconvert(java.lang.Object value)Convert the specified locale-sensitive value into a String.static java.lang.Stringconvert(java.lang.Object value, java.lang.String pattern)Convert the specified locale-sensitive value into a String using the conversion pattern.static java.lang.Stringconvert(java.lang.Object value, java.util.Locale locale, java.lang.String pattern)Convert the specified locale-sensitive value into a String using the paticular convertion pattern.static java.lang.Objectconvert(java.lang.String[] values, java.lang.Class<?> clazz)Convert an array of specified values to an array of objects of the specified class (if possible).static java.lang.Objectconvert(java.lang.String[] values, java.lang.Class<?> clazz, java.lang.String pattern)Convert an array of specified values to an array of objects of the specified class (if possible) using the convertion pattern.static java.lang.Objectconvert(java.lang.String[] values, java.lang.Class<?> clazz, java.util.Locale locale, java.lang.String pattern)Convert an array of specified values to an array of objects of the specified class (if possible) using the convertion pattern.static java.lang.Objectconvert(java.lang.String value, java.lang.Class<?> clazz)Convert the specified value to an object of the specified class (if possible).static java.lang.Objectconvert(java.lang.String value, java.lang.Class<?> clazz, java.lang.String pattern)Convert the specified value to an object of the specified class (if possible) using the convertion pattern.static java.lang.Objectconvert(java.lang.String value, java.lang.Class<?> clazz, java.util.Locale locale, java.lang.String pattern)Convert the specified value to an object of the specified class (if possible) using the convertion pattern.protected static org.apache.commons.collections.FastHashMapcreate(java.util.Locale locale)Deprecated.This method will be modified to return a Map in the next release.static voidderegister()Remove any registeredLocaleConverter.static voidderegister(java.lang.Class<?> clazz, java.util.Locale locale)Remove any registeredLocaleConverterfor the specified locale and Class.static voidderegister(java.util.Locale locale)Remove any registeredLocaleConverterfor the specified locale.static booleangetApplyLocalized()Gets applyLocalized.static java.util.LocalegetDefaultLocale()Gets theLocalewhich will be used when noLocaleis passed to a method.static LocaleConverterlookup(java.lang.Class<?> clazz, java.util.Locale locale)Look up and return any registeredLocaleConverterfor the specified destination class and locale; if there is no registered Converter, returnnull.protected static org.apache.commons.collections.FastHashMaplookup(java.util.Locale locale)Deprecated.This method will be modified to return a Map in the next release.static voidregister(LocaleConverter converter, java.lang.Class<?> clazz, java.util.Locale locale)Register a customLocaleConverterfor the specified destinationClass, replacing any previously registered converter.static voidsetApplyLocalized(boolean newApplyLocalized)Sets applyLocalized.static voidsetDefaultLocale(java.util.Locale locale)Sets theLocalewhich will be used when noLocaleis passed to a method.
-
-
-
Method Detail
-
convert
public static java.lang.String convert(java.lang.Object value)
Convert the specified locale-sensitive value into a String.
For more details see
LocaleConvertUtilsBean- Parameters:
value- The Value to be converted- Returns:
- the converted value
- See Also:
LocaleConvertUtilsBean.convert(Object)
-
convert
public static java.lang.String convert(java.lang.Object value, java.util.Locale locale, java.lang.String pattern)Convert the specified locale-sensitive value into a String using the paticular convertion pattern.
For more details see
LocaleConvertUtilsBean- Parameters:
value- The Value to be convertedlocale- The localepattern- The convertion pattern- Returns:
- the converted value
- See Also:
LocaleConvertUtilsBean.convert(Object, Locale, String)
-
convert
public static java.lang.String convert(java.lang.Object value, java.lang.String pattern)Convert the specified locale-sensitive value into a String using the conversion pattern.
For more details see
LocaleConvertUtilsBean- Parameters:
value- The Value to be convertedpattern- The convertion pattern- Returns:
- the converted value
- See Also:
LocaleConvertUtilsBean.convert(Object, String)
-
convert
public static java.lang.Object convert(java.lang.String value, java.lang.Class<?> clazz)Convert the specified value to an object of the specified class (if possible). Otherwise, return a String representation of the value.
For more details see
LocaleConvertUtilsBean- Parameters:
value- The String scalar value to be convertedclazz- The Data type to which this value should be converted.- Returns:
- the converted value
- See Also:
LocaleConvertUtilsBean.convert(String, Class)
-
convert
public static java.lang.Object convert(java.lang.String value, java.lang.Class<?> clazz, java.util.Locale locale, java.lang.String pattern)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.
For more details see
LocaleConvertUtilsBean- Parameters:
value- The String scalar value to be convertedclazz- The Data type to which this value should be converted.locale- The localepattern- The convertion pattern- Returns:
- the converted value
- See Also:
LocaleConvertUtilsBean.convert(String, Class, Locale, String)
-
convert
public static java.lang.Object convert(java.lang.String value, java.lang.Class<?> clazz, java.lang.String pattern)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.
For more details see
LocaleConvertUtilsBean- Parameters:
value- The String scalar value to be convertedclazz- The Data type to which this value should be converted.pattern- The convertion pattern- Returns:
- the converted value
- See Also:
LocaleConvertUtilsBean.convert(String, Class, String)
-
convert
public static java.lang.Object convert(java.lang.String[] values, java.lang.Class<?> clazz)Convert an array of specified values to an array of objects of the specified class (if possible).
For more details see
LocaleConvertUtilsBean- Parameters:
values- Value to be converted (may be null)clazz- Java array or element class to be converted to- Returns:
- the converted value
- See Also:
LocaleConvertUtilsBean.convert(String[], Class)
-
convert
public static java.lang.Object convert(java.lang.String[] values, java.lang.Class<?> clazz, java.util.Locale locale, java.lang.String pattern)Convert an array of specified values to an array of objects of the specified class (if possible) using the convertion pattern.
For more details see
LocaleConvertUtilsBean- Parameters:
values- Value to be converted (may be null)clazz- Java array or element class to be converted tolocale- The localepattern- The convertion pattern- Returns:
- the converted value
- See Also:
LocaleConvertUtilsBean.convert(String[], Class, Locale, String)
-
convert
public static java.lang.Object convert(java.lang.String[] values, java.lang.Class<?> clazz, java.lang.String pattern)Convert an array of specified values to an array of objects of the specified class (if possible) using the convertion pattern.
For more details see
LocaleConvertUtilsBean- Parameters:
values- Value to be converted (may be null)clazz- Java array or element class to be converted topattern- The convertion pattern- Returns:
- the converted value
- See Also:
LocaleConvertUtilsBean.convert(String[], Class, String)
-
create
@Deprecated protected static org.apache.commons.collections.FastHashMap create(java.util.Locale locale)
Deprecated.This method will be modified to return a Map in the next release.Create all
LocaleConvertertypes for specified locale.For more details see
LocaleConvertUtilsBean- Parameters:
locale- The Locale- Returns:
- The FastHashMap instance contains the all
LocaleConvertertypes for the specified locale. - See Also:
LocaleConvertUtilsBean.create(Locale)
-
deregister
public static void deregister()
Remove any registered
LocaleConverter.For more details see
LocaleConvertUtilsBean- See Also:
LocaleConvertUtilsBean.deregister()
-
deregister
public static void deregister(java.lang.Class<?> clazz, java.util.Locale locale)Remove any registered
LocaleConverterfor the specified locale and Class.For more details see
LocaleConvertUtilsBean- Parameters:
clazz- Class for which to remove a registered Converterlocale- The locale- See Also:
LocaleConvertUtilsBean.deregister(Class, Locale)
-
deregister
public static void deregister(java.util.Locale locale)
Remove any registered
LocaleConverterfor the specified locale.For more details see
LocaleConvertUtilsBean- Parameters:
locale- The locale- See Also:
LocaleConvertUtilsBean.deregister(Locale)
-
getApplyLocalized
public static boolean getApplyLocalized()
Gets applyLocalized.
For more details see
LocaleConvertUtilsBean- Returns:
trueif pattern is localized, otherwisefalse- See Also:
LocaleConvertUtilsBean.getApplyLocalized()
-
getDefaultLocale
public static java.util.Locale getDefaultLocale()
Gets the
Localewhich will be used when noLocaleis passed to a method.For more details see
LocaleConvertUtilsBean- Returns:
- the default locale
- See Also:
LocaleConvertUtilsBean.getDefaultLocale()
-
lookup
public static LocaleConverter lookup(java.lang.Class<?> clazz, java.util.Locale locale)
Look up and return any registered
LocaleConverterfor the specified destination class and locale; if there is no registered Converter, returnnull.For more details see
LocaleConvertUtilsBean- Parameters:
clazz- Class for which to return a registered Converterlocale- The Locale- Returns:
- The registered locale Converter, if any
- See Also:
LocaleConvertUtilsBean.lookup(Class, Locale)
-
lookup
@Deprecated protected static org.apache.commons.collections.FastHashMap lookup(java.util.Locale locale)
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.
For more details see
LocaleConvertUtilsBean- Parameters:
locale- The Locale- Returns:
- The FastHashMap instance contains the all
LocaleConvertertypes for the specified locale. - See Also:
LocaleConvertUtilsBean.lookup(Locale)
-
register
public static void register(LocaleConverter converter, java.lang.Class<?> clazz, java.util.Locale locale)
Register a custom
LocaleConverterfor the specified destinationClass, replacing any previously registered converter.For more details see
LocaleConvertUtilsBean- Parameters:
converter- The LocaleConverter to be registeredclazz- The Destination class for conversions performed by this Converterlocale- The locale- See Also:
LocaleConvertUtilsBean.register(LocaleConverter, Class, Locale)
-
setApplyLocalized
public static void setApplyLocalized(boolean newApplyLocalized)
Sets applyLocalized.
For more details see
LocaleConvertUtilsBean- Parameters:
newApplyLocalized-trueif pattern is localized, otherwisefalse- See Also:
LocaleConvertUtilsBean.setApplyLocalized(boolean)
-
setDefaultLocale
public static void setDefaultLocale(java.util.Locale locale)
Sets the
Localewhich will be used when noLocaleis passed to a method.For more details see
LocaleConvertUtilsBean- Parameters:
locale- the default locale- See Also:
LocaleConvertUtilsBean.setDefaultLocale(Locale)
-
-