org.codehaus.waffle.bind.converters
Class NumberListValueConverter
java.lang.Object
org.codehaus.waffle.bind.converters.AbstractValueConverter
org.codehaus.waffle.bind.converters.StringListValueConverter
org.codehaus.waffle.bind.converters.NumberListValueConverter
- All Implemented Interfaces:
- ValueConverter
public class NumberListValueConverter
- extends StringListValueConverter
ValueConverter that converts a CSV value to a List of Numbers. It extends
StringListValueConverter to provide number
parsing of the string values using the NumberFormat instance provided (which defaults to
NumberFormat.getInstance()) and if not successful returns the string values themselves.
- Author:
- Mauro Talevi
|
Method Summary |
boolean |
accept(java.lang.reflect.Type type)
Accepts parameterized types of raw type List and argument type Number |
protected java.lang.Object |
convertMissingValue(java.lang.String key,
java.lang.String defaultMessage,
java.lang.Object... parameters)
Handles the case of a missing value. |
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 |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NumberListValueConverter
public NumberListValueConverter(MessageResources messageResources)
NumberListValueConverter
public NumberListValueConverter(MessageResources messageResources,
java.util.Properties patterns,
java.text.NumberFormat numberFormat)
accept
public boolean accept(java.lang.reflect.Type type)
- Accepts parameterized types of raw type List and argument type Number
- Specified by:
accept in interface ValueConverter- Overrides:
accept in class StringListValueConverter
- Parameters:
type - the Type a value is to be bound to
- Returns:
- A boolean
true is type is compatible
convertValue
public java.lang.Object convertValue(java.lang.String propertyName,
java.lang.String value,
java.lang.reflect.Type toType)
- Description copied from interface:
ValueConverter
- Converts a String value to an Object of a given type
- Specified by:
convertValue in interface ValueConverter- Overrides:
convertValue in class StringListValueConverter
- Parameters:
propertyName - the associated property name, which can be null, also needed to present
customized error messages.value - the String valuetoType - the Object Type
- Returns:
- The converted Object
convertMissingValue
protected java.lang.Object convertMissingValue(java.lang.String key,
java.lang.String defaultMessage,
java.lang.Object... parameters)
- Description copied from class:
AbstractValueConverter
- Handles the case of a missing value. By default it return a
null converted value, but can be
overridden to throw a BindException
- Overrides:
convertMissingValue in class StringListValueConverter
- Parameters:
key - the error message keydefaultMessage - the default message if key is not foundparameters - the message formatting parameters
- Returns:
- A converted object when value is missing,
null by default.
Copyright © 2008. All Rights Reserved.