org.codehaus.waffle.bind
Interface ValueConverter

All Known Implementing Classes:
AbstractValueConverter, DateValueConverter, EnumValueConverter, NumberListValueConverter, NumberValueConverter, OgnlValueConverter, StringListMapValueConverter, StringListValueConverter, StringNumberListMapValueConverter

public interface ValueConverter

Implementation of this interface will be responsible for converting String values to the specific type. These are registered with Waffle through the web.xml.

Author:
Michael Ward, Mauro Talevi

Method Summary
 boolean accept(java.lang.reflect.Type type)
          Determines if converter is compatible with the given type
 java.lang.Object convertValue(java.lang.String propertyName, java.lang.String value, java.lang.reflect.Type toType)
          Converts a String value to an Object of a given type
 

Method Detail

accept

boolean accept(java.lang.reflect.Type type)
Determines if converter is compatible with the given type

Parameters:
type - the Type a value is to be bound to
Returns:
A boolean true is type is compatible

convertValue

java.lang.Object convertValue(java.lang.String propertyName,
                              java.lang.String value,
                              java.lang.reflect.Type toType)
Converts a String value to an Object of a given type

Parameters:
propertyName - the associated property name, which can be null, also needed to present customized error messages.
value - the String value
toType - the Object Type
Returns:
The converted Object
Throws:
BindException - if conversion fails


Copyright © 2008. All Rights Reserved.