Class AbstractConverter
- java.lang.Object
-
- com.norconex.commons.lang.convert.AbstractConverter
-
- All Implemented Interfaces:
IConverter
- Direct Known Subclasses:
BooleanConverter,CharacterConverter,CharsetConverter,ClassConverter,ContentTypeConverter,DateConverter,DimensionConverter,DurationConverter,EnumConverter,FileConverter,InstantConverter,LocalDateTimeConverter,LocaleConverter,NumberConverter,StringConverter,URLConverter,ZonedDateTimeConverter
public abstract class AbstractConverter extends Object implements IConverter
Adds default behaviors common to most converters, including checking for
nullvalues and wrapping exceptions inConverterException.- Since:
- 2.0.0
- Author:
- Pascal Essiembre
- See Also:
ConverterException
-
-
Constructor Summary
Constructors Constructor Description AbstractConverter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanequals(Object other)inthashCode()protected abstract StringnullSafeToString(Object object)protected abstract <T> TnullSafeToType(String value, Class<T> type)StringtoString()StringtoString(Object object)protected ConverterExceptiontoStringException(Object object)protected ConverterExceptiontoStringException(Object object, Throwable e)<T> TtoType(String value, Class<T> type)protected ConverterExceptiontoTypeException(String value, Class<?> type)protected ConverterExceptiontoTypeException(String value, Class<?> type, Throwable e)protected ConverterExceptiontoUnsupportedTypeException(Object obj)-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.norconex.commons.lang.convert.IConverter
toString, toType
-
-
-
-
Method Detail
-
toType
public final <T> T toType(String value, Class<T> type)
- Specified by:
toTypein interfaceIConverter
-
toString
public final String toString(Object object)
- Specified by:
toStringin interfaceIConverter
-
nullSafeToType
protected abstract <T> T nullSafeToType(String value, Class<T> type) throws Exception
- Throws:
Exception
-
nullSafeToString
protected abstract String nullSafeToString(Object object) throws Exception
- Throws:
Exception
-
toUnsupportedTypeException
protected ConverterException toUnsupportedTypeException(Object obj)
-
toTypeException
protected ConverterException toTypeException(String value, Class<?> type)
-
toTypeException
protected ConverterException toTypeException(String value, Class<?> type, Throwable e)
-
toStringException
protected ConverterException toStringException(Object object)
-
toStringException
protected ConverterException toStringException(Object object, Throwable e)
-
-