org.mentawai.rule
Class IntegerRule

java.lang.Object
  extended by org.mentawai.rule.BasicRule
      extended by org.mentawai.rule.IntegerRule
All Implemented Interfaces:
Rule

public class IntegerRule
extends BasicRule

A rule to validate integers. You can also specify min and max values.

Author:
Sergio Oliveira

Constructor Summary
IntegerRule()
           
IntegerRule(int min)
          Creates a IntegerRule with a min value.
IntegerRule(int min, int max)
          Creates a IntegerRule with a min and max values.
 
Method Summary
 boolean check(String value)
          Check a single input value from this action.
static IntegerRule getInstance()
           
static IntegerRule getInstance(int min)
           
static IntegerRule getInstance(int min, int max)
           
 Map<String,String> getTokens()
          Returns a map with tokens that can be used in the error messages.
 
Methods inherited from class org.mentawai.rule.BasicRule
check
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntegerRule

public IntegerRule()

IntegerRule

public IntegerRule(int min)
Creates a IntegerRule with a min value.

Parameters:
min - The minimum value for the integer.

IntegerRule

public IntegerRule(int min,
                   int max)
Creates a IntegerRule with a min and max values.

Parameters:
min - The minium value for the integer.
max - The maximum value for the integer.
Method Detail

getInstance

public static IntegerRule getInstance()

getInstance

public static IntegerRule getInstance(int min)

getInstance

public static IntegerRule getInstance(int min,
                                      int max)

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 BasicRule
Returns:
A map with the token values.

check

public boolean check(String value)
Description copied from class: BasicRule
Check a single input value from this action. Override this method to implement a basic rule for validation.

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


Copyright © 2013. All Rights Reserved.