org.jwarp.service.param
Class NumberValidator

java.lang.Object
  |
  +--org.jwarp.service.param.AValidator
        |
        +--org.jwarp.service.param.NumberValidator
All Implemented Interfaces:
IConfigurable, IValidator

public class NumberValidator
extends AValidator

A validator for numbers with range check.

Version:
1.0
Author:
Anatole Tresch, Martin Schaefer

Field Summary
(package private)  double dmax
          Maximal accepted double value
(package private)  double dmin
          Minimal accepted double value
(package private)  long lmax
          Maximal accepted long value
(package private)  long lmin
          Minimal accepted long value
(package private)  short type
           
static short TYPE_FLOAT
          Number type: floating point numbers (doubles).
static short TYPE_INT
          Number type: integral numbers (longs).
static short TYPE_UNDEFINED
          Number type: undefined state.
 
Fields inherited from class org.jwarp.service.param.AValidator
contentValidator, mayBeEmpty, required
 
Constructor Summary
NumberValidator()
           
NumberValidator(double min)
          A Constructor: sets min.
NumberValidator(double min, double max)
          A Constructor: sets min and max.
NumberValidator(float min)
          A Constructor: sets min.
NumberValidator(int min)
          A Constructor: sets min.
NumberValidator(long min)
          A Constructor: sets min.
NumberValidator(long min, long max)
          A Constructor: sets min and max.
NumberValidator(short min)
          A Constructor: sets min.
 
Method Summary
 void configure(org.jdom.Element config)
          Pass the Configuration to the Configurable class.
 double getMaxFloat()
          Get the upper limit of the range
 long getMaxInt()
          Get the upper limit of the range
 double getMinFloat()
          Get the lower limit of the range
 long getMinInt()
          Get the lower limit of the range
 java.lang.String getValidationClass()
          Returns the class name of the class being validated.
 short getValidationType()
          Returns the current validation type.
 void setMax(double max)
          Sets the upper limit of the range
 void setMax(long max)
          Sets the upper limit of the range
 void setMin(double min)
          Set the lower limit of the range
 void setMin(long min)
          Set the lower limit of the range
 void validate(java.lang.Object value)
          The validate function
Checks for a float in the given range
 
Methods inherited from class org.jwarp.service.param.AValidator
getMayBeEmpty, getNextValidator, getRequired, setMayBeEmpty, setNextValidator, setRequired
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_UNDEFINED

public static final short TYPE_UNDEFINED
Number type: undefined state.

TYPE_INT

public static final short TYPE_INT
Number type: integral numbers (longs).

TYPE_FLOAT

public static final short TYPE_FLOAT
Number type: floating point numbers (doubles).

dmin

double dmin
Minimal accepted double value

dmax

double dmax
Maximal accepted double value

lmin

long lmin
Minimal accepted long value

lmax

long lmax
Maximal accepted long value

type

short type
Constructor Detail

NumberValidator

public NumberValidator()

NumberValidator

public NumberValidator(double min,
                       double max)
A Constructor: sets min and max. Since doubles are provided double is required and integer will raise an error on validation.
Parameters:
min - Minimal value
max - Maximal value

NumberValidator

public NumberValidator(long min,
                       long max)
A Constructor: sets min and max. Since longs are provided long is required and double will raise an error on validation.
Parameters:
min - Minimal value
max - Maximal value

NumberValidator

public NumberValidator(double min)
A Constructor: sets min. Since double is provided double is required and integer will raise an error on validation.
Parameters:
min - Minimal value

NumberValidator

public NumberValidator(float min)
A Constructor: sets min. Since double is provided double is required and integer will raise an error on validation.
Parameters:
min - Minimal value

NumberValidator

public NumberValidator(long min)
A Constructor: sets min. Since long is provided long is required and double will raise an error on validation.
Parameters:
min - Minimal value

NumberValidator

public NumberValidator(int min)
A Constructor: sets min. Since int is provided long is required and floats will raise an error on validation.
Parameters:
min - Minimal value

NumberValidator

public NumberValidator(short min)
A Constructor: sets min. Since short is provided long is required and floats will raise an error on validation.
Parameters:
min - Minimal value
Method Detail

configure

public void configure(org.jdom.Element config)
               throws ConfigurationException
Description copied from interface: IConfigurable
Pass the Configuration to the Configurable class. This method must always be called after the constructor and before any other method.
Following copied from interface: org.jwarp.service.configuration.IConfigurable
Parameters:
configuration - the class configurations.

validate

public void validate(java.lang.Object value)
              throws ParameterException
The validate function
Checks for a float in the given range
Overrides:
validate in class AValidator
Parameters:
contens - The paramter content to be checked
Returns:
false if check fails

setMin

public void setMin(long min)
Set the lower limit of the range
Parameters:
The - new lower limit

setMax

public void setMax(long max)
Sets the upper limit of the range
Parameters:
max - The new upper limit

getMinInt

public long getMinInt()
Get the lower limit of the range
Returns:
The current lower limit

getMaxInt

public long getMaxInt()
Get the upper limit of the range
Returns:
The current upper limit

setMin

public void setMin(double min)
Set the lower limit of the range
Parameters:
The - new lower limit

setMax

public void setMax(double max)
Sets the upper limit of the range
Parameters:
max - The new upper limit

getMinFloat

public double getMinFloat()
Get the lower limit of the range
Returns:
The current lower limit

getMaxFloat

public double getMaxFloat()
Get the upper limit of the range
Returns:
The current upper limit

getValidationClass

public java.lang.String getValidationClass()
Returns the class name of the class being validated.
Returns:
the full class name

getValidationType

public short getValidationType()
Returns the current validation type.

©   O R C A   S y s t e m s