net.sourceforge.stripes.validation
Class BooleanTypeConverter

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

public class BooleanTypeConverter
extends Object
implements TypeConverter<Boolean>

Performs a fairly aggressive conversion of a String to a boolean. The String will be deemed to be equivalent to true if it meets any of the following conditions:

If none of the above conditions are met, the return value is false. This type converter does not produce any validation errors - it always returns either true or false.

Author:
Tim Fennell

Constructor Summary
BooleanTypeConverter()
           
 
Method Summary
 Boolean convert(String input, Class<? extends Boolean> targetType, Collection<ValidationError> errors)
          Converts a String to a Boolean in accordance with the specification laid out in the class level javadoc.
 void setLocale(Locale locale)
          Does nothing currently due to the fact that there is no localization support for Booleans in Java.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BooleanTypeConverter

public BooleanTypeConverter()
Method Detail

setLocale

public void setLocale(Locale locale)
Does nothing currently due to the fact that there is no localization support for Booleans in Java.

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

convert

public Boolean convert(String input,
                       Class<? extends Boolean> targetType,
                       Collection<ValidationError> errors)
Converts a String to a Boolean in accordance with the specification laid out in the class level javadoc.

Specified by:
convert in interface TypeConverter<Boolean>
Parameters:
input - the String being converted
targetType - 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.