public abstract class BaseLocaleConverter extends Object implements LocaleConverter
The base class for all standart type locale-sensitive converters.
It has LocaleConverter
and Converter
implementations,
that convert an incoming locale-sensitive Object into an object of correspond type,
optionally using a default value or throwing a ConversionException
if a conversion error occurs.
Modifier and Type | Field and Description |
---|---|
protected Locale |
locale
The locale specified to our Constructor, by default - system locale.
|
protected boolean |
locPattern
The flag indicating whether the given pattern string is localized or not.
|
protected String |
pattern
The default pattern specified to our Constructor, if any.
|
protected boolean |
useDefault
Should we return the default value on conversion errors?
|
Modifier | Constructor and Description |
---|---|
protected |
BaseLocaleConverter(Locale locale,
String pattern)
Create a
LocaleConverter that will throw a ConversionException
if a conversion error occurs. |
protected |
BaseLocaleConverter(Locale locale,
String pattern,
boolean locPattern)
Create a
LocaleConverter that will throw a ConversionException
if a conversion error occurs. |
protected |
BaseLocaleConverter(Object defaultValue,
Locale locale,
String pattern)
Create a
LocaleConverter that will return the specified default value
if a conversion error occurs. |
protected |
BaseLocaleConverter(Object defaultValue,
Locale locale,
String pattern,
boolean locPattern)
Create a
LocaleConverter that will return the specified default value
if a conversion error occurs. |
Modifier and Type | Method and Description |
---|---|
<T> T |
convert(Class<T> type,
Object value)
Convert the specified locale-sensitive input object into an output object of the
specified type.
|
<T> T |
convert(Class<T> type,
Object value,
String pattern)
Convert the specified locale-sensitive input object into an output object of the
specified type.
|
Object |
convert(Object value)
Convert the specified locale-sensitive input object into an output object.
|
Object |
convert(Object value,
String pattern)
Convert the specified locale-sensitive input object into an output object.
|
protected abstract Object |
parse(Object value,
String pattern)
Convert the specified locale-sensitive input object into an output object of the
specified type.
|
protected boolean useDefault
protected boolean locPattern
protected BaseLocaleConverter(Locale locale, String pattern)
LocaleConverter
that will throw a ConversionException
if a conversion error occurs.
An unlocalized pattern is used for the convertion.locale
- The localepattern
- The convertion patternprotected BaseLocaleConverter(Locale locale, String pattern, boolean locPattern)
LocaleConverter
that will throw a ConversionException
if a conversion error occurs.locale
- The localepattern
- The convertion patternlocPattern
- Indicate whether the pattern is localized or notprotected BaseLocaleConverter(Object defaultValue, Locale locale, String pattern)
LocaleConverter
that will return the specified default value
if a conversion error occurs.
An unlocalized pattern is used for the convertion.defaultValue
- The default value to be returnedlocale
- The localepattern
- The convertion patternprotected BaseLocaleConverter(Object defaultValue, Locale locale, String pattern, boolean locPattern)
LocaleConverter
that will return the specified default value
if a conversion error occurs.defaultValue
- The default value to be returnedlocale
- The localepattern
- The convertion patternlocPattern
- Indicate whether the pattern is localized or notprotected abstract Object parse(Object value, String pattern) throws ParseException
value
- The input object to be convertedpattern
- The pattern is used for the convertionParseException
- if conversion cannot be performed
successfullypublic Object convert(Object value)
value
- The input object to be convertedConversionException
- if conversion cannot be performed
successfullypublic Object convert(Object value, String pattern)
value
- The input object to be convertedpattern
- The pattern is used for the conversionConversionException
- if conversion cannot be performed
successfullypublic <T> T convert(Class<T> type, Object value)
convert
in interface Converter
T
- The desired target type of the conversiontype
- Data type to which this value should be convertedvalue
- The input object to be convertedConversionException
- if conversion cannot be performed
successfullypublic <T> T convert(Class<T> type, Object value, String pattern)
convert
in interface LocaleConverter
T
- The desired target type of the conversiontype
- Data is type to which this value should be convertedvalue
- is the input object to be convertedpattern
- is the pattern is used for the conversion; if null is
passed then the default pattern associated with the converter object
will be used.ConversionException
- if conversion cannot be performed
successfullyCopyright © 2000–2016 The Apache Software Foundation. All rights reserved.