1 58 59 61 package com.mockobjects.sql; 62 63 import java.sql.SQLException ; 64 import java.util.Map ; 65 66 83 abstract class CommonMockSingleRowResultSet extends MockResultSet { 84 85 87 private ExpectationSqlRow myRow = 88 new ExpectationSqlRow("CommonMockSingleRowResultSet.SqlRow"); 89 90 private int myNextCallCount = 0; 91 92 94 95 98 public void addExpectedIndexedValues(Object [] values) { 99 myRow.addExpectedIndexedValues(values); 100 } 101 102 106 public void addExpectedNamedValues(String [] names, Object [] values) { 107 myRow.addExpectedNamedValues(names, values); 108 } 109 110 114 public void addExpectedNamedValues(Map map) { 115 myRow.addExpectedNamedValues(map); 116 } 117 118 120 125 public CommonMockSingleRowResultSet(){ 126 super(); 127 } 128 129 133 public CommonMockSingleRowResultSet(Object [] values) { 134 addExpectedIndexedValues(values); 135 } 136 137 141 public CommonMockSingleRowResultSet(String [] names, Object [] values) { 142 addExpectedNamedValues(names, values); 143 } 144 145 149 public CommonMockSingleRowResultSet(Map map) { 150 addExpectedNamedValues(map); 151 } 152 153 155 156 159 public boolean next() throws SQLException { 160 myNextCalls.inc(); 161 myNextCallCount++; 162 return myNextCallCount == 1; 163 } 164 165 168 public int getRow() throws SQLException { 169 return myNextCallCount; 170 } 171 172 176 public Object getObject(int columnIndex) throws SQLException { 177 return myRow.get(columnIndex); 178 } 179 180 185 public Object getObject(String columnName) throws SQLException { 186 return myRow.get(columnName); 187 } 188 } | Popular Tags |