001: package com.mockrunner.mock.connector.cci;
002:
003: import java.util.HashMap;
004: import java.util.Map;
005:
006: import javax.resource.ResourceException;
007: import javax.resource.cci.ResultSetInfo;
008:
009: /**
010: * Mock implementation of <code>ResultSetInfo</code>.
011: */
012: public class MockResultSetInfo implements ResultSetInfo {
013: private Map deletesAreDetectedMap;
014: private Map insertsAreDetectedMap;
015: private Map updatesAreDetectedMap;
016: private Map othersDeletesAreVisibleMap;
017: private Map othersInsertsAreVisibleMap;
018: private Map othersUpdatesAreVisibleMap;
019: private Map ownDeletesAreVisibleMap;
020: private Map ownInsertsAreVisibleMap;
021: private Map ownUpdatesAreVisibleMap;
022: private Map supportsResultSetTypeMap;
023: private Map supportsResultTypeConcurrencyMap;
024:
025: public MockResultSetInfo() {
026: deletesAreDetectedMap = new HashMap();
027: insertsAreDetectedMap = new HashMap();
028: updatesAreDetectedMap = new HashMap();
029: othersDeletesAreVisibleMap = new HashMap();
030: othersInsertsAreVisibleMap = new HashMap();
031: othersUpdatesAreVisibleMap = new HashMap();
032: ownDeletesAreVisibleMap = new HashMap();
033: ownInsertsAreVisibleMap = new HashMap();
034: ownUpdatesAreVisibleMap = new HashMap();
035: supportsResultSetTypeMap = new HashMap();
036: supportsResultTypeConcurrencyMap = new HashMap();
037: }
038:
039: public boolean deletesAreDetected(int type)
040: throws ResourceException {
041: Boolean deletesAreDetected = (Boolean) deletesAreDetectedMap
042: .get(new Integer(type));
043: if (null == deletesAreDetected)
044: return true;
045: return deletesAreDetected.booleanValue();
046: }
047:
048: public boolean insertsAreDetected(int type)
049: throws ResourceException {
050: Boolean insertsAreDetected = (Boolean) insertsAreDetectedMap
051: .get(new Integer(type));
052: if (null == insertsAreDetected)
053: return true;
054: return insertsAreDetected.booleanValue();
055: }
056:
057: public boolean updatesAreDetected(int type)
058: throws ResourceException {
059: Boolean updatesAreDetected = (Boolean) updatesAreDetectedMap
060: .get(new Integer(type));
061: if (null == updatesAreDetected)
062: return true;
063: return updatesAreDetected.booleanValue();
064: }
065:
066: public boolean othersDeletesAreVisible(int type)
067: throws ResourceException {
068: Boolean othersDeletesAreVisible = (Boolean) othersDeletesAreVisibleMap
069: .get(new Integer(type));
070: if (null == othersDeletesAreVisible)
071: return true;
072: return othersDeletesAreVisible.booleanValue();
073: }
074:
075: public boolean othersInsertsAreVisible(int type)
076: throws ResourceException {
077: Boolean othersInsertsAreVisible = (Boolean) othersInsertsAreVisibleMap
078: .get(new Integer(type));
079: if (null == othersInsertsAreVisible)
080: return true;
081: return othersInsertsAreVisible.booleanValue();
082: }
083:
084: public boolean othersUpdatesAreVisible(int type)
085: throws ResourceException {
086: Boolean othersUpdatesAreVisible = (Boolean) othersUpdatesAreVisibleMap
087: .get(new Integer(type));
088: if (null == othersUpdatesAreVisible)
089: return true;
090: return othersUpdatesAreVisible.booleanValue();
091: }
092:
093: public boolean ownDeletesAreVisible(int type)
094: throws ResourceException {
095: Boolean ownDeletesAreVisible = (Boolean) ownDeletesAreVisibleMap
096: .get(new Integer(type));
097: if (null == ownDeletesAreVisible)
098: return true;
099: return ownDeletesAreVisible.booleanValue();
100: }
101:
102: public boolean ownInsertsAreVisible(int type)
103: throws ResourceException {
104: Boolean ownInsertsAreVisible = (Boolean) ownInsertsAreVisibleMap
105: .get(new Integer(type));
106: if (null == ownInsertsAreVisible)
107: return true;
108: return ownInsertsAreVisible.booleanValue();
109: }
110:
111: public boolean ownUpdatesAreVisible(int type)
112: throws ResourceException {
113: Boolean ownUpdatesAreVisible = (Boolean) ownUpdatesAreVisibleMap
114: .get(new Integer(type));
115: if (null == ownUpdatesAreVisible)
116: return true;
117: return ownUpdatesAreVisible.booleanValue();
118: }
119:
120: public boolean supportsResultSetType(int type)
121: throws ResourceException {
122: Boolean supportsResultSetType = (Boolean) supportsResultSetTypeMap
123: .get(new Integer(type));
124: if (null == supportsResultSetType)
125: return true;
126: return supportsResultSetType.booleanValue();
127: }
128:
129: public boolean supportsResultTypeConcurrency(int type,
130: int concurrency) throws ResourceException {
131: Boolean supportsResultTypeConcurrency = (Boolean) supportsResultTypeConcurrencyMap
132: .get(new SupportsResultTypeConcurrencyKey(type,
133: concurrency));
134: if (null == supportsResultTypeConcurrency)
135: return true;
136: return supportsResultTypeConcurrency.booleanValue();
137: }
138:
139: public void setDeletesAreDetected(int type,
140: boolean deletesAreDetected) {
141: deletesAreDetectedMap.put(new Integer(type), new Boolean(
142: deletesAreDetected));
143: }
144:
145: public void setInsertsAreDetected(int type,
146: boolean insertsAreDetected) {
147: insertsAreDetectedMap.put(new Integer(type), new Boolean(
148: insertsAreDetected));
149: }
150:
151: public void setUpdatesAreDetected(int type,
152: boolean updatesAreDetected) {
153: updatesAreDetectedMap.put(new Integer(type), new Boolean(
154: updatesAreDetected));
155: }
156:
157: public void setOthersDeletesAreVisible(int type,
158: boolean othersDeletesAreVisible) {
159: othersDeletesAreVisibleMap.put(new Integer(type), new Boolean(
160: othersDeletesAreVisible));
161: }
162:
163: public void setOthersInsertsAreVisible(int type,
164: boolean othersInsertsAreVisible) {
165: othersInsertsAreVisibleMap.put(new Integer(type), new Boolean(
166: othersInsertsAreVisible));
167: }
168:
169: public void setOthersUpdatesAreVisible(int type,
170: boolean othersUpdatesAreVisible) {
171: othersUpdatesAreVisibleMap.put(new Integer(type), new Boolean(
172: othersUpdatesAreVisible));
173: }
174:
175: public void setOwnDeletesAreVisible(int type,
176: boolean ownDeletesAreVisible) {
177: ownDeletesAreVisibleMap.put(new Integer(type), new Boolean(
178: ownDeletesAreVisible));
179: }
180:
181: public void setOwnInsertsAreVisible(int type,
182: boolean ownInsertsAreVisible) {
183: ownInsertsAreVisibleMap.put(new Integer(type), new Boolean(
184: ownInsertsAreVisible));
185: }
186:
187: public void setOwnUpdatesAreVisible(int type,
188: boolean ownUpdatesAreVisible) {
189: ownUpdatesAreVisibleMap.put(new Integer(type), new Boolean(
190: ownUpdatesAreVisible));
191: }
192:
193: public void setSupportsResultSetType(int type,
194: boolean supportsResultSetType) {
195: supportsResultSetTypeMap.put(new Integer(type), new Boolean(
196: supportsResultSetType));
197: }
198:
199: public void setSupportsResultTypeConcurrency(int type,
200: int concurrency, boolean supportsResultTypeConcurrency) {
201: supportsResultTypeConcurrencyMap
202: .put(new SupportsResultTypeConcurrencyKey(type,
203: concurrency), new Boolean(
204: supportsResultTypeConcurrency));
205: }
206:
207: private class SupportsResultTypeConcurrencyKey {
208: private int type;
209: private int concurrency;
210:
211: public SupportsResultTypeConcurrencyKey(int type,
212: int concurrency) {
213: this .type = type;
214: this .concurrency = concurrency;
215: }
216:
217: public int getType() {
218: return type;
219: }
220:
221: public int getConcurrency() {
222: return concurrency;
223: }
224:
225: public boolean equals(Object object) {
226: if (null == object)
227: return false;
228: if (!object.getClass().equals(this .getClass()))
229: return false;
230: SupportsResultTypeConcurrencyKey other = (SupportsResultTypeConcurrencyKey) object;
231: return (this .getType() == other.getType())
232: && (this .getConcurrency() == other.getConcurrency());
233: }
234:
235: public int hashCode() {
236: return ((31 + type) * 31) + concurrency;
237: }
238: }
239: }
|