org.xwiki.properties.internal.converter
Class ConvertUtilsConverter

java.lang.Object
  extended by org.xwiki.properties.internal.converter.ConvertUtilsConverter
All Implemented Interfaces:
Initializable, Converter

@Component
@Singleton
public class ConvertUtilsConverter
extends java.lang.Object
implements Converter, Initializable

ConvertUtils based converter.

It's the default Converter, the one used when no other Converter could be found by ConverterManager.

Since:
2.0M2
Version:
$Id$

Constructor Summary
ConvertUtilsConverter()
           
 
Method Summary
<T> T
convert(java.lang.reflect.Type targetType, java.lang.Object sourceValue)
          
 void initialize()
          By default ConvertUtils.convert(Object, Class) does not throw any exceptions for failed conversions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConvertUtilsConverter

public ConvertUtilsConverter()
Method Detail

initialize

public void initialize()
By default ConvertUtils.convert(Object, Class) does not throw any exceptions for failed conversions. Instead it will return some default value corresponding to the target type. We must override this behavior in order to get the desired functionality.

Specified by:
initialize in interface Initializable

convert

public <T> T convert(java.lang.reflect.Type targetType,
                     java.lang.Object sourceValue)

Specified by:
convert in interface Converter
Type Parameters:
T - the type in which the provided value has to be converted
Parameters:
targetType - the type in which the provided value has to be converted
sourceValue - the value to convert
Returns:
the converted value
See Also:
Converter.convert(java.lang.reflect.Type, java.lang.Object)


Copyright © 2004-2011 XWiki. All Rights Reserved.