org.dbunit.dataset.datatype
Class NumberTolerantDataType

java.lang.Object
  extended by org.dbunit.dataset.datatype.DataType
      extended by org.dbunit.dataset.datatype.AbstractDataType
          extended by org.dbunit.dataset.datatype.NumberDataType
              extended by org.dbunit.dataset.datatype.NumberTolerantDataType

public class NumberTolerantDataType
extends NumberDataType

Extended version of the NumberDataType. Extends the AbstractDataType.compare(Object, Object) method in order to respect precision tolerance. This is comparable to the JUnit method assert(double val1, double val2, double toleratedDelta).

Since:
2.3.0
Version:
$Revision: 909 $ $Date: 2008-12-04 21:20:00 +0100 (Thu, 04 Dec 2008) $
Author:
gommma, Last changed by: $Author: gommma $

Field Summary
 
Fields inherited from class org.dbunit.dataset.datatype.DataType
BIGINT, BINARY, BIT, BLOB, BOOLEAN, CHAR, CLOB, DATE, DECIMAL, DOUBLE, FLOAT, INTEGER, LONGVARBINARY, LONGVARCHAR, NUMERIC, REAL, SMALLINT, TIME, TIMESTAMP, TINYINT, UNKNOWN, VARBINARY, VARCHAR
 
Method Summary
protected  int compareNonNulls(Object value1cast, Object value2cast)
          The only method overwritten from the base implementation to compare numbers allowing a tolerance
 ToleratedDeltaMap.Precision getToleratedDelta()
           
static boolean isZero(BigDecimal value)
          Checks if the given value is zero.
 
Methods inherited from class org.dbunit.dataset.datatype.NumberDataType
getSqlValue, setSqlValue, typeCast
 
Methods inherited from class org.dbunit.dataset.datatype.AbstractDataType
areObjectsEqual, compare, getSqlType, getTypeClass, isDateTime, isNumber, loadClass, loadClass, toString
 
Methods inherited from class org.dbunit.dataset.datatype.DataType
asString, forObject, forSqlType, forSqlTypeName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getToleratedDelta

public ToleratedDeltaMap.Precision getToleratedDelta()

compareNonNulls

protected int compareNonNulls(Object value1cast,
                              Object value2cast)
                       throws TypeCastException
The only method overwritten from the base implementation to compare numbers allowing a tolerance

Overrides:
compareNonNulls in class AbstractDataType
Parameters:
value1cast - First value resulting from the DataType.typeCast(Object) method call
value2cast - Second value resulting from the DataType.typeCast(Object) method call
Returns:
The result of the Comparable.compareTo(Object) invocation.
Throws:
TypeCastException
See Also:
AbstractDataType.compareNonNulls(java.lang.Object, java.lang.Object)

isZero

public static final boolean isZero(BigDecimal value)
Checks if the given value is zero.

Parameters:
value -
Returns:
true if and only if the given value is zero.


Copyright © 2002-2012. All Rights Reserved.