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