org.apache.tapestry5.ioc.internal.services
Class TypeCoercerImpl
java.lang.Object
org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl
- All Implemented Interfaces:
- TypeCoercer
public class TypeCoercerImpl
- extends Object
- implements TypeCoercer
|
Method Summary |
void |
clearCache()
Clears cached information stored by the TypeCoercer. |
Object |
coerce(Object input,
Class targetType)
Performs a coercion from an input type to a desired output type. |
|
explain(Class<S> inputType,
Class<T> targetType)
Used primarily inside test suites, this method performs the same steps as TypeCoercer.coerce(Object, Class), but
returns a string describing the series of coercision, such as "Object --> String --> Long --> Integer". |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TypeCoercerImpl
public TypeCoercerImpl(Collection<CoercionTuple> tuples)
coerce
public Object coerce(Object input,
Class targetType)
- Description copied from interface:
TypeCoercer
- Performs a coercion from an input type to a desired output type. When the target type is a primitive, the actual
conversion will be to the equivalent wrapper type. In some cases, the TypeCoercer will need to search for an
appropriate coercion, and may even combine existing coercions to form new ones; in those cases, the results of
the search are cached.
The TypeCoercer also caches the results of a coercion search.
- Specified by:
coerce in interface TypeCoercer
targetType - defines the target type
- Returns:
- the coerced value
explain
public <S,T> String explain(Class<S> inputType,
Class<T> targetType)
- Description copied from interface:
TypeCoercer
- Used primarily inside test suites, this method performs the same steps as
TypeCoercer.coerce(Object, Class), but
returns a string describing the series of coercision, such as "Object --> String --> Long --> Integer".
- Specified by:
explain in interface TypeCoercer
- Type Parameters:
S - source type (input)T - target type (output)- Parameters:
inputType - the source coercion type (use void.class for coercions from null)targetType - defines the target type
- Returns:
- a string identifying the series of coercions, or the empty string if no coercion is necessary
clearCache
public void clearCache()
- Description copied from interface:
TypeCoercer
- Clears cached information stored by the TypeCoercer.
- Specified by:
clearCache in interface TypeCoercer
Copyright © 2006-2009 Apache Software Foundation. All Rights Reserved.