Klasse DateStringValidator
java.lang.Object
org.apache.fulcrum.intake.validator.DefaultValidator<Date>
org.apache.fulcrum.intake.validator.DateStringValidator
- Alle implementierten Schnittstellen:
org.apache.avalon.framework.logger.LogEnabled
,InitableByConstraintMap
,Validator<Date>
- Bekannte direkte Unterklassen:
DateRangeValidator
Validates numbers with the following constraints in addition to those
listed in DefaultValidator.
Name | Valid Values | Default Value |
---|---|---|
format | see SimpleDateFormat javadoc | |
formatx | see SimpleDateFormat javadoc | |
where x is >= 1 to specify multiple date formats. Only one format rule should have a message | ||
flexible | true, as long as DateFormat can parse the date, allow it, and false | false |
- Version:
- $Id$
- Autor:
- John McNally, Quinton McCombs, Colin Chalmers, Jürgen Hoffmann, Scott Eade
-
Feldübersicht
Von Klasse geerbte Felder org.apache.fulcrum.intake.validator.DefaultValidator
errorMessage, log, maxLength, maxLengthMessage, minLength, minLengthMessage, required, requiredMessage
Von Schnittstelle geerbte Felder org.apache.fulcrum.intake.validator.Validator
FLEXIBLE_RULE_NAME, FORMAT_RULE_NAME, INVALID_NUMBER_RULE_NAME, MASK_RULE_NAME, MAX_LENGTH_RULE_NAME, MAX_VALUE_RULE_NAME, MIN_LENGTH_RULE_NAME, MIN_VALUE_RULE_NAME, REQUIRED_RULE_NAME
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
assertValidity
(String testValue) Determine whether a testValue meets the criteria specified in the constraints defined for this validatorFormats a date into a String.Get the value of minLengthMessage.Get the value of dateFormats.void
init
(Map<String, ? extends Constraint> paramMap) Constructor to use when initializing Objectboolean
Get the value of flexible.Parses the String s according to the rules/formats for this validator.void
setDateFormatMessage
(String message) Only sets the message if the new message has some information.void
setDateFormats
(List<String> formats) Set the value of dateFormats.void
setFlexible
(boolean flexible) Set the value of flexible.Von Klasse geerbte Methoden org.apache.fulcrum.intake.validator.DefaultValidator
assertValidity, enableLogging, getMaxLength, getMaxLengthMessage, getMessage, getMinLength, getMinLengthMessage, getRequiredMessage, isRequired, isValid, isValid, setMaxLength, setMaxLengthMessage, setMinLength, setMinLengthMessage, setRequired, setRequiredMessage
-
Konstruktordetails
-
DateStringValidator
public DateStringValidator()Default Constructor
-
-
Methodendetails
-
init
Constructor to use when initializing Object- Angegeben von:
init
in SchnittstelleInitableByConstraintMap
- Setzt außer Kraft:
init
in KlasseDefaultValidator<Date>
- Parameter:
paramMap
- a map of parameters- Löst aus:
InvalidMaskException
- one of the mask rules is invalid
-
assertValidity
Determine whether a testValue meets the criteria specified in the constraints defined for this validator- Angegeben von:
assertValidity
in SchnittstelleValidator<Date>
- Setzt außer Kraft:
assertValidity
in KlasseDefaultValidator<Date>
- Parameter:
testValue
- aString
to be tested- Löst aus:
ValidationException
- containing an error message if the testValue did not pass the validation tests.
-
parse
Parses the String s according to the rules/formats for this validator. The formats provided by the "formatx" rules (where x is >= 1) are used before the "format" rules to allow for a display format that includes a 4 digit year, but that will parse the date using a format that accepts 2 digit years.- Parameter:
s
- possibly a date string- Gibt zurück:
- the date parsed
- Löst aus:
ParseException
- indicates that the string could not be parsed into a date.
-
format
Formats a date into a String. The format used is from the first format rule found for the field.- Parameter:
date
- the Date object to convert into a string.- Gibt zurück:
- formatted date
-
getDateFormatMessage
Get the value of minLengthMessage.- Gibt zurück:
- value of minLengthMessage.
-
setDateFormatMessage
Only sets the message if the new message has some information. So the last setMessage call with valid data wins. But later calls with null or empty string will not affect a previous valid setting.- Parameter:
message
- Value to assign to minLengthMessage.
-
getDateFormats
Get the value of dateFormats.- Gibt zurück:
- value of dateFormats.
-
setDateFormats
Set the value of dateFormats.- Parameter:
formats
- Value to assign to dateFormats.
-
isFlexible
public boolean isFlexible()Get the value of flexible.- Gibt zurück:
- value of flexible.
-
setFlexible
public void setFlexible(boolean flexible) Set the value of flexible.- Parameter:
flexible
- Value to assign to flexible.
-