org.mentawai.rule
Class DateRule

java.lang.Object
  extended by org.mentawai.rule.LocaleRule
      extended by org.mentawai.rule.DateRule
All Implemented Interfaces:
Rule

public class DateRule
extends LocaleRule

Author:
Robert Anderson Nogueira de Oliveira

Constructor Summary
DateRule()
          Creates a rule using the default DateFormat style (SHORT).
DateRule(Date min, Date max)
          Creates a rule using the default DateFormat style (SHORT).
DateRule(int style)
          Creates a rule using the given DateFormat style.
DateRule(int style, Date min, Date max)
          Creates a rule using the given DateFormat style.
DateRule(SimpleDateFormat sdf)
          Create a rule using the given SimpleDateFormat.
DateRule(SimpleDateFormat sdf, Date min, Date max)
          Create a rule using the given SimpleDateFormat.
DateRule(String pattern)
           
DateRule(String pattern, Date min, Date max)
           
 
Method Summary
 boolean check(String value, Locale locale)
          Check a single input value from this action considering its locale.
static DateRule getInstance()
           
 Map<String,String> getTokens()
          Returns a map with tokens that can be used in the error messages.
 
Methods inherited from class org.mentawai.rule.LocaleRule
check
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateRule

public DateRule()
Creates a rule using the default DateFormat style (SHORT).


DateRule

public DateRule(Date min,
                Date max)
Creates a rule using the default DateFormat style (SHORT).

Parameters:
min - Can be null or the min date.
max - Can be null or the max date.

DateRule

public DateRule(int style)
Creates a rule using the given DateFormat style.

Parameters:
style - The DateFormat style. (Ex: DateFormat.SHORT, DateFormat.FULL, etc.)

DateRule

public DateRule(int style,
                Date min,
                Date max)
Creates a rule using the given DateFormat style.

Parameters:
style - The DateFormat style. (Ex: DateFormat.SHORT, DateFormat.FULL, etc.)
min - Can be null or the min date.
max - Can be null or the max date.

DateRule

public DateRule(SimpleDateFormat sdf)
Create a rule using the given SimpleDateFormat. OBS: Note that this rule, although a LocaleRule, will ignore the locale when validating. That's because a SimpleDateFormat contains a fixed pattern that does not depend on the locale.

Parameters:
sdf - The SimpleDateFormat to use.

DateRule

public DateRule(String pattern)

DateRule

public DateRule(SimpleDateFormat sdf,
                Date min,
                Date max)
Create a rule using the given SimpleDateFormat. OBS: Note that this rule, although a LocaleRule, will ignore the locale when validating. That's because a SimpleDateFormat contains a fixed pattern that does not depend on the locale.

Parameters:
sdf - The SimpleDateFormat to use.
min - Can be null or the min date.
max - Can be null or the max date.

DateRule

public DateRule(String pattern,
                Date min,
                Date max)
Method Detail

getInstance

public static DateRule getInstance()

check

public boolean check(String value,
                     Locale locale)
Description copied from class: LocaleRule
Check a single input value from this action considering its locale. Override this method to implement a locale rule for validation.

Specified by:
check in class LocaleRule
Parameters:
value - The value to validate.
locale - The locale to consider in the validation.
Returns:
true if the validation was successful.

getTokens

public Map<String,String> getTokens()
Description copied from interface: Rule
Returns a map with tokens that can be used in the error messages. The tokens in the error messages will be replaced by the token values in this map.

Specified by:
getTokens in interface Rule
Overrides:
getTokens in class LocaleRule
Returns:
A map with the token values.


Copyright © 2013. All Rights Reserved.