Package org.apache.ofbiz.base.conversion
Class AbstractConverter<S,T>
java.lang.Object
org.apache.ofbiz.base.conversion.AbstractConverter<S,T>
- All Implemented Interfaces:
Converter<S,
,T> ConverterLoader
- Direct Known Subclasses:
AbstractLocalizedConverter
,BooleanConverters.BooleanToInteger
,BooleanConverters.BooleanToString
,BooleanConverters.IntegerToBoolean
,BooleanConverters.StringToBoolean
,CollectionConverters.ArrayToList
,CollectionConverters.ListToString
,CollectionConverters.MapToList
,CollectionConverters.MapToSet
,CollectionConverters.MapToString
,CollectionConverters.StringToMap
,Converters.GenericValueToJSON
,Converters.GenericValueToList
,Converters.GenericValueToSet
,Converters.GenericValueToString
,Converters.JSONToGenericValue
,Converters.NullFieldToObject
,Converters.ObjectToNullField
,DateTimeConverters.CalendarToDate
,DateTimeConverters.CalendarToLong
,DateTimeConverters.CalendarToString
,DateTimeConverters.CalendarToTimestamp
,DateTimeConverters.DateToLong
,DateTimeConverters.DateToSqlDate
,DateTimeConverters.DateToSqlTime
,DateTimeConverters.DateToTimestamp
,DateTimeConverters.DurationToBigDecimal
,DateTimeConverters.DurationToDouble
,DateTimeConverters.DurationToFloat
,DateTimeConverters.DurationToLong
,DateTimeConverters.DurationToString
,DateTimeConverters.NumberToDate
,DateTimeConverters.NumberToDuration
,DateTimeConverters.NumberToSqlDate
,DateTimeConverters.NumberToSqlTime
,DateTimeConverters.NumberToTimestamp
,DateTimeConverters.SqlDateToDate
,DateTimeConverters.SqlDateToTime
,DateTimeConverters.SqlDateToTimestamp
,DateTimeConverters.SqlTimeToSqlDate
,DateTimeConverters.StringToTimeZone
,DateTimeConverters.TimestampToDate
,DateTimeConverters.TimestampToSqlDate
,DateTimeConverters.TimestampToSqlTime
,DateTimeConverters.TimeZoneToString
,GenericSingletonToList
,GenericSingletonToSet
,JSONConverters.JSONToList
,JSONConverters.JSONToMap
,JSONConverters.ListToJSON
,JSONConverters.MapToJSON
,MiscConverters.BlobToBlob
,MiscConverters.BlobToByteArray
,MiscConverters.ByteArrayToBlob
,MiscConverters.ByteArrayToByteBuffer
,MiscConverters.ByteBufferToByteArray
,MiscConverters.CharsetToString
,MiscConverters.ClobToString
,MiscConverters.DecimalFormatToString
,MiscConverters.EnumToString
,MiscConverters.LocaleToString
,MiscConverters.RegexPatternToString
,MiscConverters.SimpleDateFormatToString
,MiscConverters.StringBufferToString
,MiscConverters.StringToCharset
,MiscConverters.StringToClob
,MiscConverters.StringToDecimalFormat
,MiscConverters.StringToLocale
,MiscConverters.StringToRegexPattern
,MiscConverters.StringToSimpleDateFormat
,MiscConverters.StringToUUID
,MiscConverters.StringWrapperToString
,MiscConverters.UUIDToString
,NetConverters.InetAddressToString
,NetConverters.StringToInetAddress
,NetConverters.StringToURI
,NetConverters.StringToURL
,NetConverters.URIToString
,NetConverters.URIToURL
,NetConverters.URLToString
,NetConverters.URLToURI
,NumberConverters.DoubleToBigDecimal
,NumberConverters.FloatToBigDecimal
,NumberConverters.GenericNumberToDouble
,NumberConverters.GenericNumberToFloat
,NumberConverters.GenericNumberToInteger
,NumberConverters.GenericNumberToLong
,NumberConverters.GenericNumberToShort
,NumberConverters.IntegerToBigDecimal
,NumberConverters.IntegerToBigInteger
,NumberConverters.IntegerToByte
,NumberConverters.LongToBigDecimal
,NumberConverters.LongToByte
,NumberConverters.StringToByte
,NumberConverters.StringToShort
public abstract class AbstractConverter<S,T>
extends Object
implements Converter<S,T>, ConverterLoader
Abstract Converter class. This class handles converter registration
and it implements the
canConvert
, getSourceClass
,
and getTargetClass
methods.-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractConverter
(Class<? super S> sourceClass, Class<? super T> targetClass) -
Method Summary
Modifier and TypeMethodDescriptionboolean
canConvert
(Class<?> sourceClass, Class<?> targetClass) Returnstrue
if this object can convertsourceClass
totargetClass
.Convertsobj
toT
.Returns the sourceClass
for this converter.Returns the targetClass
for this converter.void
Create and register converters with the Java object type conversion framework.
-
Constructor Details
-
AbstractConverter
-
-
Method Details
-
loadConverters
public void loadConverters()Description copied from interface:ConverterLoader
Create and register converters with the Java object type conversion framework. If the converter extends one of the converter abstract classes, then the converter will register itself when an instance is created. Otherwise, callConverters.registerConverter(Converter)
with theConverter
instance.- Specified by:
loadConverters
in interfaceConverterLoader
-
convert
Description copied from interface:Converter
Convertsobj
toT
.- Specified by:
convert
in interfaceConverter<S,
T> - Parameters:
targetClass
- TheClass
to convert toobj
- The sourceObject
to convert- Returns:
- The converted
Object
- Throws:
ConversionException
-
canConvert
Description copied from interface:Converter
Returnstrue
if this object can convertsourceClass
totargetClass
.Implementations can accomodate class hierarchy ranges by converting super classes or interfaces.
- Specified by:
canConvert
in interfaceConverter<S,
T> - Parameters:
sourceClass
- The sourceClass
targetClass
- The targetClass
- Returns:
true
if this object can convertsourceClass
totargetClass
.
-
getSourceClass
Description copied from interface:Converter
Returns the sourceClass
for this converter.- Specified by:
getSourceClass
in interfaceConverter<S,
T> - Returns:
- The source
Class
for this converter
-
getTargetClass
Description copied from interface:Converter
Returns the targetClass
for this converter.- Specified by:
getTargetClass
in interfaceConverter<S,
T> - Returns:
- The target
Class
for this converter
-