net.sourceforge.sqlunit.matchers
Class TypelessPercentageMatcher

java.lang.Object
  extended by net.sourceforge.sqlunit.matchers.TypelessPercentageMatcher
All Implemented Interfaces:
IMatcher

public class TypelessPercentageMatcher
extends java.lang.Object
implements IMatcher

The TypelessPercentageMatcher matches columns which may differ by a specified percentage. This can be useful when comparing numeric values across data types which have different default precisions.

Version:
$Revision: 1.3 $
Author:
Chris Watts (c_watts@users.sourceforge.net)

Constructor Summary
TypelessPercentageMatcher()
          Default constructor.
 
Method Summary
 boolean isEqual(java.lang.String source, java.lang.String target, java.util.Map args)
          Returns true if the value of the target is withing (+/-) a specified percentage tolerance value of the source if the source and target can both be converted to doubles.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypelessPercentageMatcher

public TypelessPercentageMatcher()
Default constructor.

Method Detail

isEqual

public final boolean isEqual(java.lang.String source,
                             java.lang.String target,
                             java.util.Map args)
                      throws SQLUnitException
Returns true if the value of the target is withing (+/-) a specified percentage tolerance value of the source if the source and target can both be converted to doubles. If both values are strings then the two string contents are compared directly. If either or source or target can be converted to double but the other cannot then an exception is thrown.

Specified by:
isEqual in interface IMatcher
Parameters:
source - the String representing the source to be matched.
target - the String representing the target to be matched.
args - a Map of name value pairs of arguments passed in.
Returns:
true if the matching strategy was successful.
Throws:
SQLUnitException - if there was a problem with matching.