01: package com.mockrunner.jdbc;
02:
03: import java.util.ArrayList;
04: import java.util.Collections;
05: import java.util.List;
06: import java.util.Map;
07: import java.util.TreeMap;
08:
09: import com.mockrunner.mock.jdbc.MockCallableStatement;
10:
11: /**
12: * Concrete handler for {@link MockCallableStatement}.
13: */
14: public class CallableStatementResultSetHandler extends
15: AbstractOutParameterResultSetHandler {
16: private List callableStatements;
17: private Map callbaleStatementMap;
18:
19: public CallableStatementResultSetHandler() {
20: callableStatements = new ArrayList();
21: callbaleStatementMap = new TreeMap();
22: }
23:
24: /**
25: * The <code>Connection</code> adds new statements with
26: * this method.
27: * @param statement the {@link MockCallableStatement}
28: */
29: public void addCallableStatement(MockCallableStatement statement) {
30: statement.setCallableStatementResultSetHandler(this );
31: List list = (List) callbaleStatementMap.get(statement.getSQL());
32: if (null == list) {
33: list = new ArrayList();
34: callbaleStatementMap.put(statement.getSQL(), list);
35: }
36: list.add(statement);
37: callableStatements.add(statement);
38: }
39:
40: /**
41: * Returns a <code>List</code> of all callable statements.
42: * @return the <code>List</code> of {@link MockCallableStatement} objects
43: */
44: public List getCallableStatements() {
45: return Collections.unmodifiableList(callableStatements);
46: }
47:
48: /**
49: * Returns a <code>Map</code> of all callable statements.
50: * The SQL strings map to the corresponding {@link MockCallableStatement}
51: * object.
52: * @return the <code>Map</code> of {@link MockCallableStatement} objects
53: */
54: public Map getCallableStatementMap() {
55: return Collections.unmodifiableMap(callbaleStatementMap);
56: }
57:
58: /**
59: * Clears all callable statements
60: */
61: public void clearCallableStatements() {
62: callableStatements.clear();
63: callbaleStatementMap.clear();
64: }
65: }
|