|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.beanutils.locale.LocaleConvertUtils
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.
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).
Field Summary | |
private static boolean |
applyLocalized
Indicate whether the pattern is localized or not |
private static java.util.Locale |
defaultLocale
The locale - default for convertion. |
private static org.apache.commons.logging.Log |
log
The Log instance for this class. |
private static org.apache.commons.collections.FastHashMap |
mapConverters
Every entry of the mapConverters is: key = locale value = FastHashMap of converters for the certain locale. |
Constructor Summary | |
LocaleConvertUtils()
|
Method Summary | |
static java.lang.String |
convert(java.lang.Object value)
Convert the specified locale-sensitive value into a String. |
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. |
static java.lang.String |
convert(java.lang.Object value,
java.lang.String pattern)
Convert the specified locale-sensitive value into a String using the convertion pattern. |
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. |
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. |
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). |
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. |
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. |
protected static org.apache.commons.collections.FastHashMap |
create(java.util.Locale locale)
Create all LocaleConverter types for specified locale. |
static void |
deregister()
Remove any registered LocaleConverter . |
static void |
deregister(java.lang.Class clazz,
java.util.Locale locale)
Remove any registered LocaleConverter for the specified locale and Class. |
static void |
deregister(java.util.Locale locale)
Remove any registered LocaleConverter for the specified locale |
static boolean |
getApplyLocalized()
getter for applyLocalized |
static java.util.Locale |
getDefaultLocale()
getter for defaultLocale |
static LocaleConverter |
lookup(java.lang.Class clazz,
java.util.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 static org.apache.commons.collections.FastHashMap |
lookup(java.util.Locale locale)
Look up and return any registered FastHashMap instance for the specified locale; if there is no registered one, return null . |
static void |
register(LocaleConverter converter,
java.lang.Class clazz,
java.util.Locale locale)
Register a custom LocaleConverter for the specified destination
Class , replacing any previously registered converter. |
static void |
setApplyLocalized(boolean newApplyLocalized)
setter for applyLocalized |
static void |
setDefaultLocale(java.util.Locale locale)
setter for defaultLocale |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static java.util.Locale defaultLocale
private static boolean applyLocalized
private static org.apache.commons.logging.Log log
Log
instance for this class.
private static org.apache.commons.collections.FastHashMap mapConverters
Constructor Detail |
public LocaleConvertUtils()
Method Detail |
public static java.util.Locale getDefaultLocale()
public static void setDefaultLocale(java.util.Locale locale)
public static boolean getApplyLocalized()
public static void setApplyLocalized(boolean newApplyLocalized)
public static java.lang.String convert(java.lang.Object value)
value
- The Value to be converted
ConversionException
- if thrown by an underlying Converterpublic static java.lang.String convert(java.lang.Object value, java.lang.String pattern)
value
- The Value to be convertedpattern
- The convertion pattern
ConversionException
- if thrown by an underlying Converterpublic static java.lang.String convert(java.lang.Object value, java.util.Locale locale, java.lang.String pattern)
value
- The Value to be convertedlocale
- The localepattern
- The convertion pattern
ConversionException
- if thrown by an underlying Converterpublic static java.lang.Object convert(java.lang.String value, java.lang.Class clazz)
value
- The String scalar value to be convertedclazz
- The Data type to which this value should be converted.
ConversionException
- if thrown by an underlying Converterpublic static java.lang.Object convert(java.lang.String value, java.lang.Class clazz, java.lang.String pattern)
value
- The String scalar value to be convertedclazz
- The Data type to which this value should be converted.pattern
- The convertion pattern
ConversionException
- if thrown by an underlying Converterpublic static java.lang.Object convert(java.lang.String value, java.lang.Class clazz, java.util.Locale locale, java.lang.String pattern)
value
- The String scalar value to be convertedclazz
- The Data type to which this value should be converted.locale
- The localepattern
- The convertion pattern
ConversionException
- if thrown by an underlying Converterpublic static java.lang.Object convert(java.lang.String[] values, java.lang.Class clazz, java.lang.String pattern)
values
- Value to be converted (may be null)clazz
- Java array or element class to be converted topattern
- The convertion pattern
ConversionException
- if thrown by an underlying Converterpublic static java.lang.Object convert(java.lang.String[] values, java.lang.Class clazz, java.util.Locale locale, java.lang.String pattern)
values
- Value to be converted (may be null)clazz
- Java array or element class to be converted tolocale
- The localepattern
- The convertion pattern
ConversionException
- if thrown by an underlying Converterpublic static void register(LocaleConverter converter, java.lang.Class clazz, java.util.Locale locale)
LocaleConverter
for the specified destination
Class
, replacing any previously registered converter.
converter
- The LocaleConverter to be registeredclazz
- The Destination class for conversions performed by this
Converterlocale
- The localepublic static void deregister()
LocaleConverter
.
public static void deregister(java.util.Locale locale)
LocaleConverter
for the specified locale
locale
- The localepublic static void deregister(java.lang.Class clazz, java.util.Locale locale)
LocaleConverter
for the specified locale and Class.
clazz
- Class for which to remove a registered Converterlocale
- The localepublic static LocaleConverter lookup(java.lang.Class clazz, java.util.Locale locale)
LocaleConverter
for the specified
destination class and locale; if there is no registered Converter, return
null
.
clazz
- Class for which to return a registered Converterlocale
- The Localeprotected static org.apache.commons.collections.FastHashMap lookup(java.util.Locale locale)
null
.
locale
- The Locale
LocaleConverter
types for
the specified locale.protected static org.apache.commons.collections.FastHashMap create(java.util.Locale locale)
LocaleConverter
types for specified locale.
locale
- The Locale
LocaleConverter
types
for the specified locale.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |