01: package com.mockrunner.jdbc;
02:
03: import java.util.ArrayList;
04: import java.util.List;
05: import java.util.Map;
06:
07: /**
08: * Encapsulates the parameter sets for an executed
09: * {@link com.mockrunner.mock.jdbc.MockPreparedStatement} or
10: * {@link com.mockrunner.mock.jdbc.MockCallableStatement}.
11: * If the prepared statement is executed multiple times, this
12: * class contains multiple maps with the corresponding parameters.
13: * Each <code>execute</code> call creates a parameter set.
14: * A parameter set is a map, the index or the name of the
15: * parameter maps to the value.
16: */
17: public class ParameterSets {
18: private List parameterSets;
19: private String sql;
20:
21: public ParameterSets(String sql) {
22: parameterSets = new ArrayList();
23: this .sql = sql;
24: }
25:
26: /**
27: * Get the SQL string.
28: * @return the SQL string
29: */
30: public String getSQLStatement() {
31: return sql;
32: }
33:
34: /**
35: * Adds a parameter set.
36: * @param parameterSet the parameter set.
37: */
38: public void addParameterSet(Map parameterSet) {
39: parameterSets.add(parameterSet);
40: }
41:
42: /**
43: * Get the current number of parameter sets.
44: * @return the number of parameter sets
45: */
46: public int getNumberParameterSets() {
47: return parameterSets.size();
48: }
49:
50: /**
51: * Gets a parameter set for a specified index.
52: * @param indexOfParameterSet the index
53: * @return the parameter set
54: */
55: public Map getParameterSet(int indexOfParameterSet) {
56: if (indexOfParameterSet >= getNumberParameterSets())
57: return null;
58: return (Map) parameterSets.get(indexOfParameterSet);
59: }
60: }
|