Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

edu.ucsb.ccs.jaqual.standard
Class InRange  view InRange download InRange.java

java.lang.Object
  extended byedu.ucsb.ccs.jaqual.standard.InRange
All Implemented Interfaces:
edu.ucsb.ccs.jaqual.Assertion

public class InRange
extends java.lang.Object
implements edu.ucsb.ccs.jaqual.Assertion

An assertion to determine if a number falls in a given range. The assertion supports both integer and floating point comparison. You can specify whether or not the bounding values are included or excluded from the range.

Version:
$Id: InRange.java,v 1.3 2002/07/13 09:08:10 parkera Exp $

Field Summary
protected  int comparisonType
          The comparison type, either INTEGER_COMPARISON or FLOAT_COMPARISON.
static int EXCLUSIVE
          Constant to indicate the bound is exclusive.
protected static int FLOAT_COMPARISON
          Constant to indicate the comparison is performed using floating point values and a tolerance.
static int INCLUSIVE
          Constant to indicate the bound is inclusive.
protected static int INTEGER_COMPARISON
          Constant to indicate the comparison is performed using only integer values.
protected  long intMax
          Minimum bound for integer comparison.
protected  long intMin
          Maximum bound for integer comparison.
protected  int lowerMode
          The comparison mode to use for the lower bound, either INCLUSIVE or EXCLUSIVE.
protected  double realMax
          Maximum bound for floating point comparison.
protected  double realMin
          Minimum bound for floating point comparison.
protected  double tolerance
          The tolerance to use when comparing floating point numbers.
protected  int upperMode
          The comparison mode to use for the upper bound, either INCLUSIVE or EXCLUSIVE.
 
Constructor Summary
InRange(double minVal, double maxVal, double tolerance)
          Create an assertion to test that a value falls in the interval [minVal, maxVal].
InRange(double minVal, double maxVal, double tolerance, int mode)
          Create an assertion to test that a value falls in the interval [minVal, maxVal].
InRange(double minVal, double maxVal, double tolerance, int lowerMode, int upperMode)
          Create an assertion to test that a value falls in the interval [minVal, maxVal].
InRange(long minVal, long maxVal)
          Create an assertion to test that a value falls in the interval [minVal, maxVal].
InRange(long minVal, long maxVal, int mode)
          Create an assertion to test that a value falls between `minVal' and `maxVal'.
InRange(long minVal, long maxVal, int lowerMode, int upperMode)
          Create an assertion to test that a value falls between `minVal' and `maxVal'.
 
Method Summary
protected  boolean _Invariant()
           
protected  int compare(double val1, double val2)
          Compare two floating point numbers.
 boolean eval(java.lang.Object o)
          Determine if a value is in the allowed range.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INCLUSIVE

public static final int INCLUSIVE
Constant to indicate the bound is inclusive. The bounding value is included in the range.

See Also:
Constant Field Values

EXCLUSIVE

public static final int EXCLUSIVE
Constant to indicate the bound is exclusive. The bounding value is not included in the range.

See Also:
Constant Field Values

INTEGER_COMPARISON

protected static final int INTEGER_COMPARISON
Constant to indicate the comparison is performed using only integer values. Floating point values will be rounded.

See Also:
Constant Field Values

FLOAT_COMPARISON

protected static final int FLOAT_COMPARISON
Constant to indicate the comparison is performed using floating point values and a tolerance.

See Also:
Constant Field Values

lowerMode

protected int lowerMode
The comparison mode to use for the lower bound, either INCLUSIVE or EXCLUSIVE.


upperMode

protected int upperMode
The comparison mode to use for the upper bound, either INCLUSIVE or EXCLUSIVE.


intMin

protected long intMin
Maximum bound for integer comparison.


intMax

protected long intMax
Minimum bound for integer comparison.


realMin

protected double realMin
Minimum bound for floating point comparison.


realMax

protected double realMax
Maximum bound for floating point comparison.


tolerance

protected double tolerance
The tolerance to use when comparing floating point numbers.


comparisonType

protected int comparisonType
The comparison type, either INTEGER_COMPARISON or FLOAT_COMPARISON.

Constructor Detail

InRange

public InRange(long minVal,
               long maxVal)
Create an assertion to test that a value falls in the interval [minVal, maxVal]. The bounds are inclusive, and the values are integers.


InRange

public InRange(long minVal,
               long maxVal,
               int mode)
Create an assertion to test that a value falls between `minVal' and `maxVal'. The values are integers.


InRange

public InRange(long minVal,
               long maxVal,
               int lowerMode,
               int upperMode)
Create an assertion to test that a value falls between `minVal' and `maxVal'. The values are integers.


InRange

public InRange(double minVal,
               double maxVal,
               double tolerance)
Create an assertion to test that a value falls in the interval [minVal, maxVal]. The bounds are inclusive, and the values are floating point.


InRange

public InRange(double minVal,
               double maxVal,
               double tolerance,
               int mode)
Create an assertion to test that a value falls in the interval [minVal, maxVal]. The values are floating point.


InRange

public InRange(double minVal,
               double maxVal,
               double tolerance,
               int lowerMode,
               int upperMode)
Create an assertion to test that a value falls in the interval [minVal, maxVal]. The values are floating point.

Method Detail

eval

public boolean eval(java.lang.Object o)
             throws java.lang.IllegalArgumentException
Determine if a value is in the allowed range. If the comparison type is FLOAT_COMPARISON, the comparison is performed using a tolerance.

Specified by:
eval in interface edu.ucsb.ccs.jaqual.Assertion

compare

protected int compare(double val1,
                      double val2)
Compare two floating point numbers.


_Invariant

protected boolean _Invariant()