public class

SimpleTypeConverter

extends PropertyEditorRegistrySupport
implements TypeConverter
java.lang.Object
   ↳ org.springframework.beans.PropertyEditorRegistrySupport
     ↳ org.springframework.beans.SimpleTypeConverter

Class Overview

Simple implementation of the TypeConverter interface that does not operate on any specific target object. This is an alternative to using a full-blown BeanWrapperImpl instance for arbitrary type conversion needs.

See Also

Summary

Public Constructors
SimpleTypeConverter()
Public Methods
<T> T convertIfNecessary(Object value, Class<T> requiredType)
Convert the value to the required type (if necessary from a String).
<T> T convertIfNecessary(Object value, Class<T> requiredType, MethodParameter methodParam)
Convert the value to the required type (if necessary from a String).
[Expand]
Inherited Methods
From class org.springframework.beans.PropertyEditorRegistrySupport
From class java.lang.Object
From interface org.springframework.beans.PropertyEditorRegistry
From interface org.springframework.beans.TypeConverter

Public Constructors

public SimpleTypeConverter ()

Also: SpringBeans

Public Methods

public T convertIfNecessary (Object value, Class<T> requiredType)

Also: SpringBeans

Convert the value to the required type (if necessary from a String).

Conversions from String to any type will typically use the setAsText method of the PropertyEditor class. Note that a PropertyEditor must be registered for the given class for this to work; this is a standard JavaBeans API. A number of PropertyEditors are automatically registered.

Parameters
value the value to convert
requiredType the type we must convert to (or null if not known, for example in case of a collection element)
Returns
  • the new value, possibly the result of type conversion

public T convertIfNecessary (Object value, Class<T> requiredType, MethodParameter methodParam)

Convert the value to the required type (if necessary from a String).

Conversions from String to any type will typically use the setAsText method of the PropertyEditor class. Note that a PropertyEditor must be registered for the given class for this to work; this is a standard JavaBeans API. A number of PropertyEditors are automatically registered.

Parameters
value the value to convert
requiredType the type we must convert to (or null if not known, for example in case of a collection element)
methodParam the method parameter that is the target of the conversion (for analysis of generic types; may be null)
Returns
  • the new value, possibly the result of type conversion