Class GenericTypeValidator
java.lang.Object
org.apache.commons.validator.GenericTypeValidator
- All Implemented Interfaces:
Serializable
This class contains basic methods for performing validations that return the
correctly typed class based on the validation performed.
- Version:
- $Revision: 1649191 $
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.apache.commons.logging.Logprivate static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ByteformatByte(String value) Checks if the value can safely be converted to a byte primitive.static ByteformatByte(String value, Locale locale) Checks if the value can safely be converted to a byte primitive.static LongformatCreditCard(String value) Checks if the field is a valid credit card number.static DateformatDate(String value, String datePattern, boolean strict) Checks if the field is a valid date.static DateformatDate(String value, Locale locale) Checks if the field is a valid date.static DoubleformatDouble(String value) Checks if the value can safely be converted to a double primitive.static DoubleformatDouble(String value, Locale locale) Checks if the value can safely be converted to a double primitive.static FloatformatFloat(String value) Checks if the value can safely be converted to a float primitive.static FloatformatFloat(String value, Locale locale) Checks if the value can safely be converted to a float primitive.static IntegerChecks if the value can safely be converted to a int primitive.static IntegerChecks if the value can safely be converted to an int primitive.static LongformatLong(String value) Checks if the value can safely be converted to a long primitive.static LongformatLong(String value, Locale locale) Checks if the value can safely be converted to a long primitive.static ShortformatShort(String value) Checks if the value can safely be converted to a short primitive.static ShortformatShort(String value, Locale locale) Checks if the value can safely be converted to a short primitive.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
LOG
private static final org.apache.commons.logging.Log LOG
-
-
Constructor Details
-
GenericTypeValidator
public GenericTypeValidator()
-
-
Method Details
-
formatByte
-
formatByte
-
formatShort
-
formatShort
-
formatInt
-
formatInt
-
formatLong
-
formatLong
-
formatFloat
-
formatFloat
-
formatDouble
-
formatDouble
Checks if the value can safely be converted to a double primitive.- Parameters:
value- The value validation is being performed on.locale- The locale to use to parse the number (system default if null)- Returns:
- the converted Double value.
-
formatDate
Checks if the field is a valid date.The
Localeis used withjava.text.DateFormat. TheDateFormat.setLenient(boolean)method is set tofalsefor all.- Parameters:
value- The value validation is being performed on.locale- The Locale to use to parse the date (system default if null)- Returns:
- the converted Date value.
-
formatDate
Checks if the field is a valid date.The pattern is used with
java.text.SimpleDateFormat. If strict is true, then the length will be checked so '2/12/1999' will not pass validation with the format 'MM/dd/yyyy' because the month isn't two digits. TheDateFormat.setLenient(boolean)method is set tofalsefor all.- Parameters:
value- The value validation is being performed on.datePattern- The pattern passed toSimpleDateFormat.strict- Whether or not to have an exact match of the datePattern.- Returns:
- the converted Date value.
-
formatCreditCard
-