net.sourceforge.stripes.validation
Class CharacterTypeConverter

java.lang.Object
  extended by net.sourceforge.stripes.validation.CharacterTypeConverter
All Implemented Interfaces:
TypeConverter<Character>

public class CharacterTypeConverter
extends Object
implements TypeConverter<Character>

Simple type converter that converts the input String to a Character by returning the first character in the String.

Since:
Stripes 1.4
Author:
Tim Fennell

Constructor Summary
CharacterTypeConverter()
           
 
Method Summary
 Character convert(String input, Class<? extends Character> targetType, Collection<ValidationError> errors)
          Converts the input String to a Character by taking the first character in the String and returning it.
 void setLocale(Locale locale)
          Does nothing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CharacterTypeConverter

public CharacterTypeConverter()
Method Detail

setLocale

public void setLocale(Locale locale)
Does nothing.

Specified by:
setLocale in interface TypeConverter<Character>
Parameters:
locale - the locale that the TypeConverter will be converting from.

convert

public Character convert(String input,
                         Class<? extends Character> targetType,
                         Collection<ValidationError> errors)
Converts the input String to a Character by taking the first character in the String and returning it. If the String is null or empty (this should never happen) then it will return the Character represented by ordinal 0, aka the null character.

Specified by:
convert in interface TypeConverter<Character>
Parameters:
input - the String to convert into a single Character
targetType - the type to convert to
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.