|
||||||||||
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<SOURCE>
SOURCE
- is the generic type of the values to convert.public abstract class AbstractGenericValueConverter<SOURCE>
This is the abstract base implementation of the GenericValueConverter
interface.
Constructor Summary | |
---|---|
AbstractGenericValueConverter()
The constructor. |
Method Summary | ||
---|---|---|
|
convertValue(SOURCE value,
Object valueSource,
Class<TARGET> targetClass)
This method converts the given value to the given
type . |
|
|
convertValue(SOURCE value,
Object valueSource,
Class<TARGET> targetClass,
TARGET defaultValue)
This method converts the given value to the given
type . |
|
|
convertValue(SOURCE value,
Object valueSource,
Class<TARGET> type,
Type targetType,
TARGET defaultValue)
This method converts the given value to the given
type . |
|
|
convertValue(SOURCE value,
Object valueSource,
TARGET minimum,
TARGET maximum)
This method converts the given value to a numeric type and
also validates that it is in the given range from minimum to
maximum . |
|
|
convertValue(SOURCE value,
Object valueSource,
TARGET minimum,
TARGET maximum,
TARGET defaultValue)
This method gets a numeric value and also validates that it is in the given range from minimum to maximum . |
Methods inherited from class net.sf.mmm.util.component.base.AbstractLoggableComponent |
---|
doInitialize, 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.GenericValueConverter |
---|
convertValue |
Constructor Detail |
---|
public AbstractGenericValueConverter()
Method Detail |
---|
public <TARGET> TARGET convertValue(SOURCE value, Object valueSource, Class<TARGET> targetClass) throws ValueNotSetException, WrongValueTypeException
value
to the given
type
.
convertValue
in interface GenericValueConverter<SOURCE>
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 final <TARGET> TARGET convertValue(SOURCE value, Object valueSource, Class<TARGET> type, Type targetType, TARGET defaultValue) throws WrongValueTypeException
value
to the given
type
.
convertValue
in interface GenericValueConverter<SOURCE>
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.type
- 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.defaultValue
- is returned if the given value
is
null
. It may also be null
.
value
converted to type
or the
defaultValue
if value
was
null
. It will only return null
if both
value
and defaultValue
are
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(SOURCE value, Object valueSource, Class<TARGET> targetClass, TARGET defaultValue) throws WrongValueTypeException
value
to the given
type
.
convertValue
in interface GenericValueConverter<SOURCE>
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.defaultValue
- is returned if the given value
is
null
. It may also be null
.
value
converted to type
or the
defaultValue
if value
was
null
. It will only return null
if both
value
and defaultValue
are
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 extends Number> TARGET convertValue(SOURCE value, Object valueSource, TARGET minimum, TARGET maximum, TARGET defaultValue) throws WrongValueTypeException, ValueOutOfRangeException
minimum
to maximum
.
convertValue
in interface GenericValueConverter<SOURCE>
TARGET
- is the numeric-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.minimum
- is the minimum number allowed. Use MIN_VALUE (e.g.
Double.MIN_VALUE
) if unbound.maximum
- is the maximum number allowed. Use MAX_VALUE (e.g.
Long.MAX_VALUE
) if unbound.defaultValue
- is the default returned if value
is
null
. It may be null
. Else it must be in
the given range from minimum
to maximum
.
value
converted to
<TARGET>
in the range from minimum
to maximum
or the defaultValue
if
value
is null
. Will only be
null
if both value
and
defaultValue
are null
.
WrongValueTypeException
- if the value is NO number.
ValueOutOfRangeException
- if the value is NOT in the given range
from minimum
to maximum
.public <TARGET extends Number> TARGET convertValue(SOURCE value, Object valueSource, TARGET minimum, TARGET maximum) throws ValueNotSetException, WrongValueTypeException, ValueOutOfRangeException
value
to a numeric type and
also validates that it is in the given range from minimum
to
maximum
.
convertValue
in interface GenericValueConverter<SOURCE>
TARGET
- is the numeric-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.minimum
- is the minimum number allowed. Use MIN_VALUE (e.g.
Double.MIN_VALUE
) if unbound.maximum
- is the maximum number allowed. Use MAX_VALUE (e.g.
Long.MAX_VALUE
) if unbound.
minimum
and maximum
.
ValueNotSetException
- if the given value
is
null
.
WrongValueTypeException
- if the value is NO number.
ValueOutOfRangeException
- if the value is NOT in the given range
from minimum
to maximum
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |