1 package com.mockobjects.sql; 2 3 import com.mockobjects.MockObject; 4 import com.mockobjects.ReturnObjectList; 5 import com.mockobjects.ExpectationList; 6 7 import java.sql.ResultSetMetaData ; 8 import java.sql.SQLException ; 9 10 13 class CommonMockResultSetMetaData extends MockObject implements ResultSetMetaData { 14 private final ReturnObjectList myNames = 15 new ReturnObjectList("MockResultSetMetaData.columnNames"); 16 private final ReturnObjectList myTypes = 17 new ReturnObjectList("MockResultSetMetaData.columnTypes"); 18 private final ReturnObjectList myClassNames = 19 new ReturnObjectList("MockResultSetMetaData.columnClassNames"); 20 private int myColumnCount; 21 private final ExpectationList myColumnTypeIndexes = 22 new ExpectationList("Column Type Indexes"); 23 private final ExpectationList myColumnNameIndexes = 24 new ExpectationList("Column Name Indexes"); 25 private final ExpectationList myColumnClassNameIndexes = 26 new ExpectationList("Column Class Name Indexes"); 27 28 31 public void setupGetColumnCount(int aColumnCount) { 32 myColumnCount = aColumnCount; 33 } 34 35 39 public void setupAddColumnNames(String [] allNames) { 40 if (allNames != null) { 41 for (int i = 0; i < allNames.length; i++) { 42 setupAddColumnName(allNames[i]); 43 } 44 } 45 } 46 47 50 public void setupAddColumnName(String aName) { 51 this.myNames.addObjectToReturn(aName); 52 } 53 54 58 public void setupAddColumnTypes(int[] allTypes) { 59 if (allTypes != null) { 60 for (int i = 0; i < allTypes.length; i++) { 61 setupAddColumnType(allTypes[i]); 62 } 63 } 64 } 65 66 69 public void setupAddColumnType(int aType) { 70 this.myTypes.addObjectToReturn(aType); 71 } 72 73 77 public int getColumnCount() throws SQLException { 78 return myColumnCount; 79 } 80 81 89 public String getColumnName(int aColumnIndex) throws SQLException { 90 myColumnNameIndexes.addActual(aColumnIndex); 91 return (String ) myNames.nextReturnObject(); 92 } 93 94 98 public void addExpectedColumnNameIndex(int aColumnIndex){ 99 myColumnNameIndexes.addExpected(aColumnIndex); 100 } 101 102 109 public int getColumnType(int aColumnIndex) throws SQLException { 110 myColumnTypeIndexes.addActual(aColumnIndex); 111 return ((Integer ) myTypes.nextReturnObject()).intValue(); 112 } 113 114 118 public void addExpectedColumnTypeIndex(int aColumnIndex){ 119 myColumnTypeIndexes.addExpected(aColumnIndex); 120 } 121 122 126 public boolean isAutoIncrement(int arg0) throws SQLException { 127 notImplemented(); 128 return false; 129 } 130 131 135 public boolean isCaseSensitive(int arg0) throws SQLException { 136 notImplemented(); 137 return false; 138 } 139 140 144 public boolean isSearchable(int arg0) throws SQLException { 145 notImplemented(); 146 return false; 147 } 148 149 153 public boolean isCurrency(int arg0) throws SQLException { 154 notImplemented(); 155 return false; 156 } 157 158 162 public int isNullable(int arg0) throws SQLException { 163 notImplemented(); 164 return 0; 165 } 166 167 171 public boolean isSigned(int arg0) throws SQLException { 172 notImplemented(); 173 return false; 174 } 175 176 180 public int getColumnDisplaySize(int arg0) throws SQLException { 181 notImplemented(); 182 return 0; 183 } 184 185 189 public String getColumnLabel(int arg0) throws SQLException { 190 notImplemented(); 191 return null; 192 } 193 194 198 public String getColumnTypeName(int arg0) throws SQLException { 199 notImplemented(); 200 return null; 201 } 202 203 207 public String getSchemaName(int arg0) throws SQLException { 208 notImplemented(); 209 return null; 210 } 211 212 216 public int getPrecision(int arg0) throws SQLException { 217 notImplemented(); 218 return 0; 219 } 220 221 225 public int getScale(int arg0) throws SQLException { 226 notImplemented(); 227 return 0; 228 } 229 230 234 public String getTableName(int arg0) throws SQLException { 235 notImplemented(); 236 return null; 237 } 238 239 243 public String getCatalogName(int arg0) throws SQLException { 244 notImplemented(); 245 return null; 246 } 247 248 252 public boolean isReadOnly(int arg0) throws SQLException { 253 notImplemented(); 254 return false; 255 } 256 257 261 public boolean isWritable(int arg0) throws SQLException { 262 notImplemented(); 263 return false; 264 } 265 266 270 public boolean isDefinitelyWritable(int arg0) throws SQLException { 271 notImplemented(); 272 return false; 273 } 274 275 279 public void setupAddColumnClassNames(String [] allNames) { 280 if (allNames != null) { 281 for (int i = 0; i < allNames.length; i++) { 282 setupAddColumnClassName(allNames[i]); 283 } 284 } 285 } 286 287 290 public void setupAddColumnClassName(String aName) { 291 this.myClassNames.addObjectToReturn(aName); 292 } 293 294 302 public String getColumnClassName(int aColumnIndex) throws SQLException { 303 myColumnClassNameIndexes.addActual(aColumnIndex); 304 return (String ) myClassNames.nextReturnObject(); 305 } 306 307 311 public void addExpectedColumnClassNameIndex(int aColumnIndex){ 312 myColumnClassNameIndexes.addExpected(aColumnIndex); 313 } 314 315 } 316 | Popular Tags |