|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.mmm.util.component.base.AbstractComponent
net.sf.mmm.util.component.base.AbstractLoggableComponent
net.sf.mmm.util.value.base.AbstractGenericValueConverter<Object>
net.sf.mmm.util.value.base.AbstractComposedValueConverter
public abstract class AbstractComposedValueConverter
This is the abstract base implementation of the
ComposedValueConverter
interface.
Field Summary | |
---|---|
private ReflectionUtil |
reflectionUtil
|
Constructor Summary | |
---|---|
AbstractComposedValueConverter()
The constructor. |
Method Summary | ||
---|---|---|
Object |
convert(Object value,
Object valueSource,
Class<? extends Object> targetClass)
This method converts the given pojo to the
<TARGET>-type. |
|
|
convertValue(Object value,
Object valueSource,
Class<TARGET> targetClass)
This method converts the given value to the given
type . |
|
|
convertValue(Object value,
Object valueSource,
Class<TARGET> targetClass,
Type targetType)
This method converts the given value to the given
type . |
|
protected void |
doInitialize()
This method performs the actual initialization . |
|
ReflectionUtil |
getReflectionUtil()
This method gets the ReflectionUtilImpl instance to use. |
|
Class<Object> |
getSourceType()
This the type of the value accepted by this converter. |
|
Class<Object> |
getTargetType()
Is the guaranteed return-type of the conversion . |
|
void |
setReflectionUtil(ReflectionUtil reflectionUtil)
|
Methods inherited from class net.sf.mmm.util.value.base.AbstractGenericValueConverter |
---|
convertValue, convertValue, convertValue, convertValue |
Methods inherited from class net.sf.mmm.util.component.base.AbstractLoggableComponent |
---|
getLogger, setLogger |
Methods inherited from class net.sf.mmm.util.component.base.AbstractComponent |
---|
doInitialized, getInitializationState, initialize |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.sf.mmm.util.value.api.ValueConverter |
---|
convert |
Methods inherited from interface net.sf.mmm.util.value.api.GenericValueConverter |
---|
convertValue, convertValue, convertValue, convertValue |
Field Detail |
---|
private ReflectionUtil reflectionUtil
getReflectionUtil()
Constructor Detail |
---|
public AbstractComposedValueConverter()
Method Detail |
---|
public ReflectionUtil getReflectionUtil()
ReflectionUtilImpl
instance to use.
ReflectionUtilImpl
to use.@Inject public void setReflectionUtil(ReflectionUtil reflectionUtil)
reflectionUtil
- is the reflectionUtil to setprotected void doInitialize()
initialization
. It is
called when AbstractComponent.initialize()
is invoked for the first time.super.AbstractComponent.doInitialize()
.
doInitialize
in class AbstractLoggableComponent
public final Class<Object> getSourceType()
Object
if you want to accept any value. A very common source-type
is String
.
getSourceType
in interface ValueConverter<Object,Object>
public final Class<Object> getTargetType()
conversion
. This information
is used externally to choose the most specific ValueConverter
that
is appropriate
for the conversion.Object
as
target-type
while a specific converter may have
Collection
as target-type
. Now
if an object (compliant with the source-type
)
needs to be converted to a Collection
or
List
, the specific converter is used while for other
objects the generic converter is chosen.target-type
is often more
general than the actual returned result
. So a ValueConverter
that converts a
comma-separated String
to an ArrayList
will
typically declare List
as target-type
.
getTargetType
in interface ValueConverter<Object,Object>
public final Object convert(Object value, Object valueSource, Class<? extends Object> targetClass)
pojo
to the
<TARGET>-type.
convert
in interface SimpleValueConverter<Object,Object>
convert
in interface ValueConverter<Object,Object>
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.targetClass
- is the type to convert the value
to.
value
or null
if the
conversion is NOT possible. The returned value has to be an
instance
of the given
targetType
.ValueConverter.convert(Object, Object, GenericType)
public <TARGET> TARGET convertValue(Object value, Object valueSource, Class<TARGET> targetClass) throws ValueNotSetException, WrongValueTypeException
value
to the given
type
.
convertValue
in interface GenericValueConverter<Object>
convertValue
in class AbstractGenericValueConverter<Object>
TARGET
- is the type to convert to.value
- is the value to convert. It may be null
.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.targetClass
- is the type the value
should be converted
to.
value
converted to type
.
ValueNotSetException
- if the given value
is
null
.
WrongValueTypeException
- if the given value
is NOT
null
but can NOT be converted to the given
type
(e.g. if value
is "12x" and
type
is Integer.class
).public <TARGET> TARGET convertValue(Object value, Object valueSource, Class<TARGET> targetClass, Type targetType) throws ValueNotSetException, WrongValueTypeException
value
to the given
type
.
convertValue
in interface GenericValueConverter<Object>
TARGET
- is the type to convert to.value
- is the value to convert. It may be null
.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.targetClass
- is the type the value
should be converted
to. It is the raw-type of the given targetType
.targetType
- is the type to convert the value
to. It is
potentially generic and therefore contains more detailed information
than targetClass
. E.g. the targetClass
may
be java.util.List
while this targetType
could be java.util.List<Long>
. This could help
e.g. if the value
is a string like
"2, 47, 4252525"
. The caller may supply the
targetClass
again here.
value
converted to type
.
ValueNotSetException
- if the given value
is
null
.
WrongValueTypeException
- if the given value
is NOT
null
but can NOT be converted to the given
type
(e.g. if value
is "12x" and
type
is Integer.class
).
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |