/** * Checks whether any duplicate results (with respect to a key template) were * received. * * @param template the template key. * @throws Exception if duplicate results are detected */ protected void checkForDuplicateKeys(Object[] template) throws Exception { Hashtable<Object, Object> hash = new Hashtable<Object, Object>(); int numMatches = 0; for (int i = 0; i < m_Keys.size(); i++) { Object[] current = m_Keys.get(i); // Skip non-matching keys if (!matchesTemplate(template, current)) { continue; } if (hash.containsKey(current[m_KeyIndex])) { throw new Exception("Duplicate result received:" + DatabaseUtils.arrayToString(current)); } numMatches++; hash.put(current[m_KeyIndex], current[m_KeyIndex]); } if (numMatches != m_ExpectedResultsPerAverage) { throw new Exception("Expected " + m_ExpectedResultsPerAverage + " results matching key \"" + DatabaseUtils.arrayToString(template) + "\" but got " + numMatches); } }
/** * Checks whether any duplicate results (with respect to a key template) were * received. * * @param template the template key. * @throws Exception if duplicate results are detected */ protected void checkForDuplicateKeys(Object[] template) throws Exception { Hashtable<Object, Object> hash = new Hashtable<Object, Object>(); int numMatches = 0; for (int i = 0; i < m_Keys.size(); i++) { Object[] current = m_Keys.get(i); // Skip non-matching keys if (!matchesTemplate(template, current)) { continue; } if (hash.containsKey(current[m_KeyIndex])) { throw new Exception("Duplicate result received:" + DatabaseUtils.arrayToString(current)); } numMatches++; hash.put(current[m_KeyIndex], current[m_KeyIndex]); } if (numMatches != m_ExpectedResultsPerAverage) { throw new Exception("Expected " + m_ExpectedResultsPerAverage + " results matching key \"" + DatabaseUtils.arrayToString(template) + "\" but got " + numMatches); } }
Object[] currentKey = m_Keys.get(i); if (!matchesTemplate(template, currentKey)) { continue;
Object[] currentKey = m_Keys.get(i); if (!matchesTemplate(template, currentKey)) { continue;