Class TypeConversionHandlerImpl
java.lang.Object
org.apache.velocity.util.introspection.TypeConversionHandlerImpl
- All Implemented Interfaces:
TypeConversionHandler
A conversion handler adds admissible conversions between Java types whenever Velocity introspection has to map
VTL methods and property accessors to Java methods. This implementation is the default Conversion Handler
for Velocity.
- Since:
- 2.0
- Version:
- $Id: TypeConversionHandlerImpl.java $
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static Converter<?> cache miss converter(package private) static final String(package private) static final Stringa converters cache map, initialized with the standard narrowing and string parsing conversions.(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final Stringstandard narrowing and string parsing conversions.(package private) static final String(package private) static Converter<?> basic toString converter -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConverter(Type formal, Class<?> actual, Converter<?> converter) Add the given converter to the handler.(package private) static booleancheckBounds(Number n, double min, double max) Converter<?> getNeededConverter(Type formal, Class<?> actual) Returns the appropriate Converter object needed for an explicit conversion Returns null if no conversion is needed.booleanisExplicitlyConvertible(Type formal, Class<?> actual, boolean possibleVarArg) Check to see if the conversion can be done using an explicit conversion
-
Field Details
-
standardConverterMap
standard narrowing and string parsing conversions. -
toString
basic toString converter -
cacheMiss
cache miss converter -
converterCacheMap
a converters cache map, initialized with the standard narrowing and string parsing conversions. -
BOOLEAN_TYPE
- See Also:
-
BYTE_TYPE
- See Also:
-
SHORT_TYPE
- See Also:
-
INTEGER_TYPE
- See Also:
-
LONG_TYPE
- See Also:
-
FLOAT_TYPE
- See Also:
-
DOUBLE_TYPE
- See Also:
-
CHARACTER_TYPE
- See Also:
-
BOOLEAN_CLASS
- See Also:
-
BYTE_CLASS
- See Also:
-
SHORT_CLASS
- See Also:
-
INTEGER_CLASS
- See Also:
-
LONG_CLASS
- See Also:
-
BIG_INTEGER_CLASS
- See Also:
-
FLOAT_CLASS
- See Also:
-
DOUBLE_CLASS
- See Also:
-
BIG_DECIMAL_CLASS
- See Also:
-
NUMBER_CLASS
- See Also:
-
CHARACTER_CLASS
- See Also:
-
STRING_CLASS
- See Also:
-
LOCALE_CLASS
- See Also:
-
-
Constructor Details
-
TypeConversionHandlerImpl
public TypeConversionHandlerImpl()Constructor
-
-
Method Details
-
checkBounds
-
isExplicitlyConvertible
Check to see if the conversion can be done using an explicit conversion- Specified by:
isExplicitlyConvertiblein interfaceTypeConversionHandler- Parameters:
formal- expected formal typeactual- found argument typepossibleVarArg- whether var arg is possible- Returns:
- true if actual class can be explicitely converted to expected formal type
- Since:
- 2.1
-
getNeededConverter
Returns the appropriate Converter object needed for an explicit conversion Returns null if no conversion is needed.- Specified by:
getNeededConverterin interfaceTypeConversionHandler- Parameters:
formal- expected formal typeactual- found argument type- Returns:
- null if no conversion is needed, or the appropriate Converter object
- Since:
- 2.1
-
addConverter
Add the given converter to the handler.- Specified by:
addConverterin interfaceTypeConversionHandler- Parameters:
formal- expected formal typeactual- provided argument typeconverter- converter- Since:
- 2.1
-