com.mockrunner.jdbc
Class SQLStatementMatcher

java.lang.Object
  extended by com.mockrunner.jdbc.SQLStatementMatcher

public class SQLStatementMatcher
extends java.lang.Object

Helper class for finding matching SQL statements based on various search parameters. The search parameters are:
caseSensitive do a case sensitive match (default is false)
exactMatch the strings must match exactly, the parameter caseSensitive is recognized, but useRegularExpression is irrelevant, if exactMatch is true (default is false)
useRegularExpression use regular expressions for matching, if this parameter is false, strings match, if one string starts with the other (default is false)


Constructor Summary
SQLStatementMatcher(boolean caseSensitive, boolean exactMatch)
           
SQLStatementMatcher(boolean caseSensitive, boolean exactMatch, boolean useRegularExpressions)
           
 
Method Summary
 boolean contains(java.util.Collection col, java.lang.String query, boolean queryContainsData)
          Compares all elements in the specified Collection with the specified query string using the method doStringsMatch(java.lang.String, java.lang.String).
 boolean doStringsMatch(java.lang.String source, java.lang.String query)
          Compares two strings and returns if they match.
 java.util.List getMatchingObjects(java.util.Map dataMap, java.lang.String query, boolean resolveCollection, boolean queryContainsMapData)
          Compares all keys in the specified Map with the specified query string using the method doStringsMatch(java.lang.String, java.lang.String).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLStatementMatcher

public SQLStatementMatcher(boolean caseSensitive,
                           boolean exactMatch)

SQLStatementMatcher

public SQLStatementMatcher(boolean caseSensitive,
                           boolean exactMatch,
                           boolean useRegularExpressions)
Method Detail

getMatchingObjects

public java.util.List getMatchingObjects(java.util.Map dataMap,
                                         java.lang.String query,
                                         boolean resolveCollection,
                                         boolean queryContainsMapData)
Compares all keys in the specified Map with the specified query string using the method doStringsMatch(java.lang.String, java.lang.String). If the strings match, the corresponding object from the Map is added to the resulting List.

Parameters:
dataMap - the source Map
query - the query string that must match the keys in dataMap
queryContainsMapData - only matters if isExactMatch is false, specifies if query must be contained in the Map keys (false) or if query must contain the Map keys (true)
Returns:
the result List

contains

public boolean contains(java.util.Collection col,
                        java.lang.String query,
                        boolean queryContainsData)
Compares all elements in the specified Collection with the specified query string using the method doStringsMatch(java.lang.String, java.lang.String).

Parameters:
col - the Collections
query - the query string that must match the keys in col
queryContainsData - only matters if exactMatch is false, specifies if query must be contained in the Collection data (false) or if query must contain the Collection data (true)
Returns:
true if col contains query, false otherwise

doStringsMatch

public boolean doStringsMatch(java.lang.String source,
                              java.lang.String query)
Compares two strings and returns if they match.

Parameters:
query - the query string that must match source
source - the source string
Returns:
true of the strings match, false otherwise