Class StringLocaleConverter
- java.lang.Object
-
- org.apache.commons.beanutils.locale.BaseLocaleConverter
-
- org.apache.commons.beanutils.locale.converters.StringLocaleConverter
-
- All Implemented Interfaces:
Converter,LocaleConverter
public class StringLocaleConverter extends BaseLocaleConverter
Standard
LocaleConverterimplementation that converts an incoming locale-sensitive object into ajava.lang.Stringobject, optionally using a default value or throwing aConversionExceptionif a conversion error occurs.
-
-
Field Summary
Fields Modifier and Type Field Description private org.apache.commons.logging.LoglogAll logging goes through this logger-
Fields inherited from class org.apache.commons.beanutils.locale.BaseLocaleConverter
locale, locPattern, pattern, useDefault
-
-
Constructor Summary
Constructors Constructor Description StringLocaleConverter()Create aLocaleConverterthat will throw aConversionExceptionif a conversion error occurs.StringLocaleConverter(boolean locPattern)Create aLocaleConverterthat will throw aConversionExceptionif a conversion error occurs.StringLocaleConverter(java.lang.Object defaultValue)Create aLocaleConverterthat will return the specified default value if a conversion error occurs.StringLocaleConverter(java.lang.Object defaultValue, boolean locPattern)Create aLocaleConverterthat will return the specified default value if a conversion error occurs.StringLocaleConverter(java.lang.Object defaultValue, java.util.Locale locale)Create aLocaleConverterthat will return the specified default value if a conversion error occurs.StringLocaleConverter(java.lang.Object defaultValue, java.util.Locale locale, boolean locPattern)Create aLocaleConverterthat will return the specified default value if a conversion error occurs.StringLocaleConverter(java.lang.Object defaultValue, java.util.Locale locale, java.lang.String pattern)Create aLocaleConverterthat will return the specified default value if a conversion error occurs.StringLocaleConverter(java.lang.Object defaultValue, java.util.Locale locale, java.lang.String pattern, boolean locPattern)Create aLocaleConverterthat will return the specified default value if a conversion error occurs.StringLocaleConverter(java.util.Locale locale)Create aLocaleConverterthat will throw aConversionExceptionif a conversion error occurs.StringLocaleConverter(java.util.Locale locale, boolean locPattern)Create aLocaleConverterthat will throw aConversionExceptionif a conversion error occurs.StringLocaleConverter(java.util.Locale locale, java.lang.String pattern)Create aLocaleConverterthat will throw aConversionExceptionif a conversion error occurs.StringLocaleConverter(java.util.Locale locale, java.lang.String pattern, boolean locPattern)Create aLocaleConverterthat will throw aConversionExceptionif a conversion error occurs.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.text.DecimalFormatgetDecimalFormat(java.util.Locale locale, java.lang.String pattern)Make an instance of DecimalFormat.protected java.lang.Objectparse(java.lang.Object value, java.lang.String pattern)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
-
-
-
-
Constructor Detail
-
StringLocaleConverter
public StringLocaleConverter()
Create aLocaleConverterthat will throw aConversionExceptionif 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 aLocaleConverterthat will throw aConversionExceptionif 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
public StringLocaleConverter(java.util.Locale locale)
Create aLocaleConverterthat will throw aConversionExceptionif a conversion error occurs. An unlocalized pattern is used for the convertion.- Parameters:
locale- The locale
-
StringLocaleConverter
public StringLocaleConverter(java.util.Locale locale, boolean locPattern)Create aLocaleConverterthat will throw aConversionExceptionif a conversion error occurs.- Parameters:
locale- The localelocPattern- Indicate whether the pattern is localized or not
-
StringLocaleConverter
public StringLocaleConverter(java.util.Locale locale, java.lang.String pattern)Create aLocaleConverterthat will throw aConversionExceptionif a conversion error occurs. An unlocalized pattern is used for the convertion.- Parameters:
locale- The localepattern- The convertion pattern
-
StringLocaleConverter
public StringLocaleConverter(java.util.Locale locale, java.lang.String pattern, boolean locPattern)Create aLocaleConverterthat will throw aConversionExceptionif a conversion error occurs.- Parameters:
locale- The localepattern- The convertion patternlocPattern- Indicate whether the pattern is localized or not
-
StringLocaleConverter
public StringLocaleConverter(java.lang.Object defaultValue)
Create aLocaleConverterthat 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
public StringLocaleConverter(java.lang.Object defaultValue, boolean locPattern)Create aLocaleConverterthat 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
public StringLocaleConverter(java.lang.Object defaultValue, java.util.Locale locale)Create aLocaleConverterthat 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
public StringLocaleConverter(java.lang.Object defaultValue, java.util.Locale locale, boolean locPattern)Create aLocaleConverterthat 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
public StringLocaleConverter(java.lang.Object defaultValue, java.util.Locale locale, java.lang.String pattern)Create aLocaleConverterthat 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(java.lang.Object defaultValue, java.util.Locale locale, java.lang.String pattern, boolean locPattern)Create aLocaleConverterthat 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 Detail
-
getDecimalFormat
private java.text.DecimalFormat getDecimalFormat(java.util.Locale locale, java.lang.String pattern)Make an instance of DecimalFormat.- Parameters:
locale- The localepattern- The pattern is used for the convertion- Returns:
- The format for the locale and pattern
- Throws:
ConversionException- if conversion cannot be performed successfullyjava.text.ParseException- if an error occurs parsing a String to a Number
-
parse
protected java.lang.Object parse(java.lang.Object value, java.lang.String pattern) throws java.text.ParseExceptionConvert the specified locale-sensitive input object into an output object of the specified type.- Specified by:
parsein 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 successfullyjava.text.ParseException- if an error occurs
-
-