net.sourceforge.stripes.validation
Class EnumeratedTypeConverter
java.lang.Object
net.sourceforge.stripes.validation.EnumeratedTypeConverter
- All Implemented Interfaces:
- TypeConverter<Enum>
public class EnumeratedTypeConverter
- extends Object
- implements TypeConverter<Enum>
Converts the String form of an Enumerated type into the Enum value that it represents. If the
String does not represent one of the values in the Enum a validation error will be set.
- Author:
- Tim Fennell
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EnumeratedTypeConverter
public EnumeratedTypeConverter()
setLocale
public void setLocale(Locale locale)
- Does nothing at present due to the fact that enumerated types don't support localization
all that well.
- Specified by:
setLocale
in interface TypeConverter<Enum>
- Parameters:
locale
- the locale that the TypeConverter will be converting from.
convert
public Enum convert(String input,
Class<? extends Enum> targetType,
Collection<ValidationError> errors)
- Description copied from interface:
TypeConverter
- Convert a String to the target type supported by this converter.
- Specified by:
convert
in interface TypeConverter<Enum>
- Parameters:
input
- the String being convertedtargetType
- the Class representing the type of the property to which the return
value of the conversion will be assigned. In many cases this can be ignored as
converters will return a single type more often than not.errors
- an empty collection of validation errors that should be populated by the
converter for any errors that occur during validation that are user input related.
- Returns:
- T an instance of the converted type, or null if the input cannot be converted
? Copyright 2005-2006, Stripes Development Team.