SOURCE - is the generic type of the values to convert.public abstract class AbstractGenericValueConverter<SOURCE> extends AbstractLoggableComponent implements GenericValueConverter<SOURCE>
GenericValueConverter interface.| Constructor and Description |
|---|
AbstractGenericValueConverter()
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
<TARGET> TARGET |
convertValue(SOURCE value,
Object valueSource,
Class<TARGET> targetClass)
This method converts the given
value to the given type. |
<TARGET> TARGET |
convertValue(SOURCE value,
Object valueSource,
Class<TARGET> targetClass,
TARGET defaultValue)
This method converts the given
value to the given type. |
<TARGET> TARGET |
convertValue(SOURCE value,
Object valueSource,
Class<TARGET> type,
Type targetType,
TARGET defaultValue)
This method converts the given
value to the given type. |
<TARGET extends Number> |
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. |
<TARGET extends Number> |
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. |
createLogger, doInitialize, getLoggerdoInitialized, getInitializationState, initializeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitconvertValuepublic AbstractGenericValueConverter()
public <TARGET> TARGET convertValue(SOURCE value, Object valueSource, Class<TARGET> targetClass) throws ValueNotSetException, WrongValueTypeException
GenericValueConvertervalue 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).ValueNotSetExceptionWrongValueTypeExceptionpublic final <TARGET> TARGET convertValue(SOURCE value, Object valueSource, Class<TARGET> type, Type targetType, TARGET defaultValue) throws WrongValueTypeException
GenericValueConvertervalue 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).WrongValueTypeExceptionpublic <TARGET> TARGET convertValue(SOURCE value, Object valueSource, Class<TARGET> targetClass, TARGET defaultValue) throws WrongValueTypeException
GenericValueConvertervalue 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).WrongValueTypeExceptionpublic <TARGET extends Number> TARGET convertValue(SOURCE value, Object valueSource, TARGET minimum, TARGET maximum, TARGET defaultValue) throws WrongValueTypeException, ValueOutOfRangeException
GenericValueConverterminimum 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.WrongValueTypeExceptionValueOutOfRangeExceptionpublic <TARGET extends Number> TARGET convertValue(SOURCE value, Object valueSource, TARGET minimum, TARGET maximum) throws ValueNotSetException, WrongValueTypeException, ValueOutOfRangeException
GenericValueConvertervalue 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.ValueNotSetExceptionWrongValueTypeExceptionValueOutOfRangeExceptionCopyright © 2001–2016 mmm-Team. All rights reserved.