Class StringLocaleConverter
java.lang.Object
org.apache.commons.beanutils.locale.BaseLocaleConverter
org.apache.commons.beanutils.locale.converters.StringLocaleConverter
- All Implemented Interfaces:
Converter
,LocaleConverter
Standard LocaleConverter
implementation that converts an incoming
locale-sensitive object into a java.lang.String
object,
optionally using a default value or throwing a
ConversionException
if a conversion error occurs.
- Version:
- $Id$
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.apache.commons.logging.Log
All logging goes through this loggerFields inherited from class org.apache.commons.beanutils.locale.BaseLocaleConverter
locale, locPattern, pattern, useDefault
-
Constructor Summary
ConstructorsConstructorDescriptionCreate aLocaleConverter
that will throw aConversionException
if a conversion error occurs.StringLocaleConverter
(boolean locPattern) Create aLocaleConverter
that will throw aConversionException
if a conversion error occurs.StringLocaleConverter
(Object defaultValue) Create aLocaleConverter
that will return the specified default value if a conversion error occurs.StringLocaleConverter
(Object defaultValue, boolean locPattern) Create aLocaleConverter
that will return the specified default value if a conversion error occurs.StringLocaleConverter
(Object defaultValue, Locale locale) Create aLocaleConverter
that will return the specified default value if a conversion error occurs.StringLocaleConverter
(Object defaultValue, Locale locale, boolean locPattern) Create aLocaleConverter
that will return the specified default value if a conversion error occurs.StringLocaleConverter
(Object defaultValue, Locale locale, String pattern) Create aLocaleConverter
that will return the specified default value if a conversion error occurs.StringLocaleConverter
(Object defaultValue, Locale locale, String pattern, boolean locPattern) Create aLocaleConverter
that will return the specified default value if a conversion error occurs.StringLocaleConverter
(Locale locale) Create aLocaleConverter
that will throw aConversionException
if a conversion error occurs.StringLocaleConverter
(Locale locale, boolean locPattern) Create aLocaleConverter
that will throw aConversionException
if a conversion error occurs.StringLocaleConverter
(Locale locale, String pattern) Create aLocaleConverter
that will throw aConversionException
if a conversion error occurs.StringLocaleConverter
(Locale locale, String pattern, boolean locPattern) Create aLocaleConverter
that will throw aConversionException
if a conversion error occurs. -
Method Summary
Modifier and TypeMethodDescriptionprivate DecimalFormat
getDecimalFormat
(Locale locale, String pattern) Make an instance of DecimalFormat.protected Object
Convert the specified locale-sensitive input object into an output object of the specified type.Methods inherited from class org.apache.commons.beanutils.locale.BaseLocaleConverter
convert, convert, convert, convert
-
Field Details
-
log
private final org.apache.commons.logging.Log logAll logging goes through this logger
-
-
Constructor Details
-
StringLocaleConverter
public StringLocaleConverter()Create aLocaleConverter
that will throw aConversionException
if a conversion error occurs. The locale is the default locale for this instance of the Java Virtual Machine and an unlocalized pattern is used for the convertion. -
StringLocaleConverter
public StringLocaleConverter(boolean locPattern) Create aLocaleConverter
that will throw aConversionException
if a conversion error occurs. The locale is the default locale for this instance of the Java Virtual Machine.- Parameters:
locPattern
- Indicate whether the pattern is localized or not
-
StringLocaleConverter
Create aLocaleConverter
that will throw aConversionException
if a conversion error occurs. An unlocalized pattern is used for the convertion.- Parameters:
locale
- The locale
-
StringLocaleConverter
Create aLocaleConverter
that will throw aConversionException
if a conversion error occurs.- Parameters:
locale
- The localelocPattern
- Indicate whether the pattern is localized or not
-
StringLocaleConverter
Create aLocaleConverter
that will throw aConversionException
if a conversion error occurs. An unlocalized pattern is used for the convertion.- Parameters:
locale
- The localepattern
- The convertion pattern
-
StringLocaleConverter
Create aLocaleConverter
that will throw aConversionException
if a conversion error occurs.- Parameters:
locale
- The localepattern
- The convertion patternlocPattern
- Indicate whether the pattern is localized or not
-
StringLocaleConverter
Create aLocaleConverter
that will return the specified default value if a conversion error occurs. The locale is the default locale for this instance of the Java Virtual Machine and an unlocalized pattern is used for the convertion.- Parameters:
defaultValue
- The default value to be returned
-
StringLocaleConverter
Create aLocaleConverter
that will return the specified default value if a conversion error occurs. The locale is the default locale for this instance of the Java Virtual Machine.- Parameters:
defaultValue
- The default value to be returnedlocPattern
- Indicate whether the pattern is localized or not
-
StringLocaleConverter
Create aLocaleConverter
that will return the specified default value if a conversion error occurs. An unlocalized pattern is used for the convertion.- Parameters:
defaultValue
- The default value to be returnedlocale
- The locale
-
StringLocaleConverter
Create aLocaleConverter
that will return the specified default value if a conversion error occurs.- Parameters:
defaultValue
- The default value to be returnedlocale
- The localelocPattern
- Indicate whether the pattern is localized or not
-
StringLocaleConverter
Create aLocaleConverter
that will return the specified default value if a conversion error occurs. An unlocalized pattern is used for the convertion.- Parameters:
defaultValue
- The default value to be returnedlocale
- The localepattern
- The convertion pattern
-
StringLocaleConverter
public StringLocaleConverter(Object defaultValue, Locale locale, String pattern, boolean locPattern) Create aLocaleConverter
that will return the specified default value if a conversion error occurs.- Parameters:
defaultValue
- The default value to be returnedlocale
- The localepattern
- The convertion patternlocPattern
- Indicate whether the pattern is localized or not
-
-
Method Details
-
parse
Convert the specified locale-sensitive input object into an output object of the specified type.- Specified by:
parse
in classBaseLocaleConverter
- Parameters:
value
- The input object to be convertedpattern
- The pattern is used for the convertion- Returns:
- The converted value
- Throws:
ConversionException
- if conversion cannot be performed successfullyParseException
- if an error occurs
-
getDecimalFormat
Make an instance of DecimalFormat.- Parameters:
locale
- The localepattern
- The pattern is used for the convertion- Returns:
- The format for the locale and pattern
-