View Javadoc
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;
26  
27  /**
28   * @author Manuel Laflamme
29   * @since Aug 11, 2003
30   * @version $Revision$
31   */
32  public class ExtendedMockSingleRowResultSet extends MockSingleRowResultSet
33  {
34      private Object _lastValue = null;
35  
36      public Object getObject(String s) throws SQLException
37      {
38          Object object = super.getObject(s);
39          _lastValue = object;
40          return object;
41      }
42  
43      public Object getObject(int i) throws SQLException
44      {
45          Object object = super.getObject(i);
46          _lastValue = object;
47          return object;
48      }
49  
50      public boolean getBoolean(int i) throws SQLException
51      {
52          Object object = getObject(i);
53          if (object == null)
54          {
55              return false;
56          }
57          return super.getBoolean(i);
58      }
59  
60      public boolean getBoolean(String s) throws SQLException
61      {
62          Object 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
71      {
72          Object object = getObject(i);
73          if (object == null)
74          {
75              return 0;
76          }
77          return super.getByte(i);
78      }
79  
80      public byte getByte(String s) throws SQLException
81      {
82          Object 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
91      {
92          Object object = getObject(i);
93          if (object == null)
94          {
95              return 0;
96          }
97          return super.getDouble(i);
98      }
99  
100     public double getDouble(String s) throws SQLException
101     {
102         Object 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
111     {
112         Object object = getObject(i);
113         if (object == null)
114         {
115             return 0;
116         }
117         return super.getFloat(i);
118     }
119 
120     public float getFloat(String s) throws SQLException
121     {
122         Object 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
131     {
132         Object object = getObject(i);
133         if (object == null)
134         {
135             return 0;
136         }
137         return super.getInt(i);
138     }
139 
140     public int getInt(String s) throws SQLException
141     {
142         Object 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
151     {
152         Object object = getObject(i);
153         if (object == null)
154         {
155             return 0;
156         }
157         return super.getLong(i);
158     }
159 
160     public long getLong(String s) throws SQLException
161     {
162         Object object = getObject(s);
163         if (object == null)
164         {
165             return 0;
166         }
167         return super.getLong(s);
168     }
169 
170     public short getShort(String s) throws SQLException
171     {
172         Object 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
181     {
182         Object 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
191     {
192         return _lastValue == null;
193     }
194 }