net.sf.mmm.util.value.base
Class AbstractSimpleValueConverter<SOURCE,TARGET>
java.lang.Object
net.sf.mmm.util.component.base.AbstractComponent
net.sf.mmm.util.component.base.AbstractLoggableComponent
net.sf.mmm.util.value.base.AbstractSimpleValueConverter<SOURCE,TARGET>
- Type Parameters:
SOURCE
- is the generic source-type
.TARGET
- is the generic target-type
.
- All Implemented Interfaces:
- SimpleValueConverter<SOURCE,TARGET>, ValueConverter<SOURCE,TARGET>
- Direct Known Subclasses:
- ValueConverterToBoolean, ValueConverterToCalendar, ValueConverterToDate, ValueConverterToEnum, ValueConverterToFile, ValueConverterToNumber, ValueConverterToString
public abstract class AbstractSimpleValueConverter<SOURCE,TARGET>
- extends AbstractLoggableComponent
- implements ValueConverter<SOURCE,TARGET>
This is an abstract base-implementation of the ValueConverter
interface that simply works with Class
rather than
GenericType
.
- Since:
- 1.0.1
- Author:
- Joerg Hohwiller (hohwille at users.sourceforge.net)
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AbstractSimpleValueConverter
public AbstractSimpleValueConverter()
- The constructor.
convert
public final TARGET convert(SOURCE value,
Object valueSource,
GenericType<? extends TARGET> targetType)
- This method converts the given
pojo
to the
<TARGET>-type.
- Specified by:
convert
in interface ValueConverter<SOURCE,TARGET>
- Parameters:
value
- is the value to convert.valueSource
- describes the source of the value. This may be the
filename where the value was read from, an XPath where the value was
located in an XML document, etc. It is used in exceptions thrown if
something goes wrong. This will help to find the problem easier.targetType
- is the GenericType
to convert the
value
to. It is potentially generic and therefore
contains more detailed information than a Class
. E.g. the
targetType
could be
java.util.List<Long>
. This could help e.g. if the
value
is a string like "2, 47, 4252525"
.
- Returns:
- the converted
value
or null
if the
conversion is NOT possible. The returned value has to be an
instance
of the given
targetType
.
Copyright © 2001-2010 mmm-Team. All Rights Reserved.