Package org.apache.velocity.util.introspection

# Class TypeConversionHandlerImpl

java.lang.Object
org.apache.velocity.util.introspection.TypeConversionHandlerImpl

All Implemented Interfaces:
  `TypeConversionHandler`

public class TypeConversionHandlerImpl extends Object implements 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 $
Author:
  Claude Brisson

## Constructor Summary

Constructors
Constructor
Description
`TypeConversionHandlerImpl()`
Constructor

## Method Summary

Modifier and Type
Method
Description
`void`
`addConverter(Type formal, Class<?> actual, Converter<?> converter)`
Add the given converter to the handler.
`Converter<?>`
`getNeededConverter(Type formal, Class<?> actual)`
Returns the appropriate Converter object needed for an explicit conversion Returns null if no conversion is needed.
`boolean`
`isExplicitlyConvertible(Type formal, Class<?> actual, boolean possibleVarArg)`
Check to see if the conversion can be done using an explicit conversion

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### TypeConversionHandlerImpl

public TypeConversionHandlerImpl()
Constructor

## Method Details

### isExplicitlyConvertible

public boolean isExplicitlyConvertible(Type formal, Class<?> actual, boolean possibleVarArg)
Check to see if the conversion can be done using an explicit conversion

Specified by:
  `isExplicitlyConvertible` in interface `TypeConversionHandler`
Parameters:
  `formal` - expected formal type
  `actual` - found argument type
  `possibleVarArg` - whether var arg is possible
Returns:
  true if actual class can be explicitely converted to expected formal type
Since:
  2.1

### getNeededConverter

public Converter<?> getNeededConverter(Type formal, Class<?> actual)
Returns the appropriate Converter object needed for an explicit conversion Returns null if no conversion is needed.

Specified by:
  `getNeededConverter` in interface `TypeConversionHandler`
Parameters:
  `formal` - expected formal type
  `actual` - found argument type
Returns:
  null if no conversion is needed, or the appropriate Converter object
Since:
  2.1

### addConverter

public void addConverter(Type formal, Class<?> actual, Converter<?> converter)
Add the given converter to the handler.

Specified by:
  `addConverter` in interface `TypeConversionHandler`
Parameters:
  `formal` - expected formal type
  `actual` - provided argument type
  `converter` - converter
Since:
  2.1