org.mentawai.rule
Class DoubleRule

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

public class DoubleRule
extends BasicRule

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

Author:
Helio Frota (idea by Emanuel Cordeiro)

Constructor Summary
DoubleRule()
          Default constructor.
DoubleRule(double min)
          Creates a IntegerRule with a min value.
DoubleRule(double min, double max)
          Creates a IntegerRule with a min and max values.
 
Method Summary
 boolean check(String value)
          Do the check.
static DoubleRule getInstance()
           
static DoubleRule getInstance(double min)
          Gets the instance.
static DoubleRule getInstance(int min, int max)
          Gets the instance.
 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

DoubleRule

public DoubleRule()
Default constructor.


DoubleRule

public DoubleRule(double min)
Creates a IntegerRule with a min value.

Parameters:
min - The minimum value for the integer.

DoubleRule

public DoubleRule(double min,
                  double 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 DoubleRule getInstance()

getInstance

public static DoubleRule getInstance(double min)
Gets the instance.

Parameters:
min - double
Returns:
DoubleRule

getInstance

public static DoubleRule getInstance(int min,
                                     int max)
Gets the instance.

Parameters:
min - double
max - double
Returns:
DoubleRule

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)
Do the check.

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


Copyright © 2013. All Rights Reserved.