org.codehaus.waffle.bind
Interface ValueConverter

All Known Implementing Classes:
OgnlValueConverter

public interface ValueConverter

Implementation of this interface will be responsible for converting values of specific type(s).

Author:
Michael Ward, Mauro Talevi

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

Method Detail

accept

boolean accept(java.lang.Class<?> type)
Determines if converter is compatible with the given type

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

convertValue

<T> T convertValue(java.lang.String propertyName,
                   java.lang.String value,
                   java.lang.Class<T> toType)
Converts a String value to an Object of a given type

Parameters:
propertyName - the associated property name, which can be null
value - the String value
toType - the Object type
Returns:
The converted Object
Throws:
BindException - if conversion fails


Copyright © 2008. All Rights Reserved.