KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dbunit > database > ExtendedMockSingleRowResultSet


1 /*
2  *
3  * The DbUnit Database Testing Framework
4  * Copyright (C)2002-2004, DbUnit.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */

21 package org.dbunit.database;
22
23 import com.mockobjects.sql.MockSingleRowResultSet;
24
25 import java.sql.SQLException JavaDoc;
26
27 /**
28  * @author Manuel Laflamme
29  * @since Aug 11, 2003
30  * @version $Revision: 1.2 $
31  */

32 public class ExtendedMockSingleRowResultSet extends MockSingleRowResultSet
33 {
34     private Object JavaDoc _lastValue = null;
35
36     public Object JavaDoc getObject(String JavaDoc s) throws SQLException JavaDoc
37     {
38         Object JavaDoc object = super.getObject(s);
39         _lastValue = object;
40         return object;
41     }
42
43     public Object JavaDoc getObject(int i) throws SQLException JavaDoc
44     {
45         Object JavaDoc object = super.getObject(i);
46         _lastValue = object;
47         return object;
48     }
49
50     public boolean getBoolean(int i) throws SQLException JavaDoc
51     {
52         Object JavaDoc object = getObject(i);
53         if (object == null)
54         {
55             return false;
56         }
57         return super.getBoolean(i);
58     }
59
60     public boolean getBoolean(String JavaDoc s) throws SQLException JavaDoc
61     {
62         Object JavaDoc object = getObject(s);
63         if (object == null)
64         {
65             return false;
66         }
67         return super.getBoolean(s);
68     }
69
70     public byte getByte(int i) throws SQLException JavaDoc
71     {
72         Object JavaDoc object = getObject(i);
73         if (object == null)
74         {
75             return 0;
76         }
77         return super.getByte(i);
78     }
79
80     public byte getByte(String JavaDoc s) throws SQLException JavaDoc
81     {
82         Object JavaDoc object = getObject(s);
83         if (object == null)
84         {
85             return 0;
86         }
87         return super.getByte(s);
88     }
89
90     public double getDouble(int i) throws SQLException JavaDoc
91     {
92         Object JavaDoc object = getObject(i);
93         if (object == null)
94         {
95             return 0;
96         }
97         return super.getDouble(i);
98     }
99
100     public double getDouble(String JavaDoc s) throws SQLException JavaDoc
101     {
102         Object JavaDoc object = getObject(s);
103         if (object == null)
104         {
105             return 0;
106         }
107         return super.getDouble(s);
108     }
109
110     public float getFloat(int i) throws SQLException JavaDoc
111     {
112         Object JavaDoc object = getObject(i);
113         if (object == null)
114         {
115             return 0;
116         }
117         return super.getFloat(i);
118     }
119
120     public float getFloat(String JavaDoc s) throws SQLException JavaDoc
121     {
122         Object JavaDoc object = getObject(s);
123         if (object == null)
124         {
125             return 0;
126         }
127         return super.getFloat(s);
128     }
129
130     public int getInt(int i) throws SQLException JavaDoc
131     {
132         Object JavaDoc object = getObject(i);
133         if (object == null)
134         {
135             return 0;
136         }
137         return super.getInt(i);
138     }
139
140     public int getInt(String JavaDoc s) throws SQLException JavaDoc
141     {
142         Object JavaDoc object = getObject(s);
143         if (object == null)
144         {
145             return 0;
146         }
147         return super.getInt(s);
148     }
149
150     public long getLong(int i) throws SQLException JavaDoc
151     {
152         Object JavaDoc object = getObject(i);
153         if (object == null)
154         {
155             return 0;
156         }
157         return super.getLong(i);
158     }
159
160     public long getLong(String JavaDoc s) throws SQLException JavaDoc
161     {
162         Object JavaDoc object = getObject(s);
163         if (object == null)
164         {
165             return 0;
166         }
167         return super.getLong(s);
168     }
169
170     public short getShort(String JavaDoc s) throws SQLException JavaDoc
171     {
172         Object JavaDoc object = getObject(s);
173         if (object == null)
174         {
175             return 0;
176         }
177         return super.getShort(s);
178     }
179
180     public short getShort(int i) throws SQLException JavaDoc
181     {
182         Object JavaDoc object = getObject(i);
183         if (object == null)
184         {
185             return 0;
186         }
187         return super.getShort(i);
188     }
189
190     public boolean wasNull() throws SQLException JavaDoc
191     {
192         return _lastValue == null;
193     }
194 }
195
Popular Tags