velosurf.validation
Class DateRange

java.lang.Object
  extended by velosurf.validation.FieldConstraint
      extended by velosurf.validation.DateRange

public class DateRange
extends FieldConstraint

A type and range constraint on dates. Syntax is:


    <column [type="date"] [after="date-after"] [before="date-before"] />
  

The type="date" parameter is implied when after or before is found.
Or:

     <column>
       <date [after="afer-date"] [before="before-date"] [message="error-message"] />
     </column>
   

The format used to specify after and before dates is yyyyMMdd. The format used to parse the input is the short local date format (which depends upon the user locale).

Author:
Claude Brisson

Field Summary
private  java.util.Date _after
           
private  java.util.Date _before
           
private  java.text.SimpleDateFormat dateFormat
           
private static java.util.regex.Pattern y4
           
private static java.text.DateFormat ymd
           
 
Fields inherited from class velosurf.validation.FieldConstraint
_message
 
Constructor Summary
DateRange()
           
 
Method Summary
private static java.lang.String reformat(java.lang.String pattern, java.lang.String date)
           
 void setAfterDate(java.util.Date after)
           
 void setBeforeDate(java.util.Date before)
           
 void setDateFormat(java.text.SimpleDateFormat dateFormat)
           
 java.lang.String toString()
           
 boolean validate(java.lang.Object data, java.util.Locale locale)
          used to validate data against this constraint
 
Methods inherited from class velosurf.validation.FieldConstraint
getMessage, setMessage, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_before

private java.util.Date _before

_after

private java.util.Date _after

dateFormat

private java.text.SimpleDateFormat dateFormat

y4

private static final java.util.regex.Pattern y4

ymd

private static java.text.DateFormat ymd
Constructor Detail

DateRange

public DateRange()
Method Detail

setBeforeDate

public void setBeforeDate(java.util.Date before)

setAfterDate

public void setAfterDate(java.util.Date after)

validate

public boolean validate(java.lang.Object data,
                        java.util.Locale locale)
Description copied from class: FieldConstraint
used to validate data against this constraint

Overrides:
validate in class FieldConstraint
Parameters:
data - to be validated
Returns:
true if the data respects the constraint, false if not

reformat

private static java.lang.String reformat(java.lang.String pattern,
                                         java.lang.String date)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setDateFormat

public void setDateFormat(java.text.SimpleDateFormat dateFormat)


~ooOoo~