View Javadoc
1   /*
2    * $Source$
3    * $Revision$
4    *
5    * Copyright (C) 2008 Tim Pizey
6    *
7    * Part of Melati (http://melati.org), a framework for the rapid
8    * development of clean, maintainable web applications.
9    *
10   * Melati is free software; Permission is granted to copy, distribute
11   * and/or modify this software under the terms either:
12   *
13   * a) the GNU General Public License as published by the Free Software
14   *    Foundation; either version 2 of the License, or (at your option)
15   *    any later version,
16   *
17   *    or
18   *
19   * b) any version of the Melati Software License, as published
20   *    at http://melati.org
21   *
22   * You should have received a copy of the GNU General Public License and
23   * the Melati Software License along with this program;
24   * if not, write to the Free Software Foundation, Inc.,
25   * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA to obtain the
26   * GNU General Public License and visit http://melati.org to obtain the
27   * Melati Software License.
28   *
29   * Feel free to contact the Developers of Melati (http://melati.org),
30   * if you would like to work out a different arrangement than the options
31   * outlined here.  It is our intention to allow Melati to be used by as
32   * wide an audience as possible.
33   *
34   * This program is distributed in the hope that it will be useful,
35   * but WITHOUT ANY WARRANTY; without even the implied warranty of
36   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37   * GNU General Public License for more details.
38   *
39   * Contact details for copyright holder:
40   *
41   *     Tim Pizey <timp At paneris.org>
42   *     http://paneris.org/~timp
43   */
44  
45  package org.melati.poem.dbms.test.sql;
46  
47  import java.io.InputStream;
48  import java.io.Reader;
49  import java.sql.NClob;
50  import java.sql.Ref;
51  import java.sql.ResultSet;
52  import java.sql.RowId;
53  import java.sql.SQLXML;
54  import java.sql.SQLException;
55  
56  /**
57   * The JDBC4 methods of a {@link Ref}, decorated to throw an SQLException on command.
58   * 
59   * @author timp
60   * @since  5 Feb 2008
61   *
62   */
63  public abstract class ThrowingResultSetJdbc4 
64      extends ThrowingResultSetJdbc3 
65      implements ResultSet {
66    
67    /**
68     *  JDBC 4.0
69     */
70    
71  
72    /** 
73     * {@inheritDoc}
74     * @see java.sql.ResultSet#getHoldability()
75     */
76  
77    public int getHoldability() throws SQLException {
78      if (shouldThrow(this.getClass().getInterfaces()[0], "getHoldability"))
79        throw new SQLException("ResultSet bombed");
80      return it.getHoldability();
81    }
82    /** 
83     * {@inheritDoc}
84     * @see java.sql.ResultSet#getNCharacterStream(int)
85     */
86  
87    public Reader getNCharacterStream(int columnIndex) throws SQLException {
88      if (shouldThrow(this.getClass().getInterfaces()[0], "getNCharacterStream"))
89        throw new SQLException("ResultSet bombed");
90      return it.getNCharacterStream(columnIndex);
91    }
92    /** 
93     * {@inheritDoc}
94     * @see java.sql.ResultSet#getNCharacterStream(java.lang.String)
95     */
96  
97    public Reader getNCharacterStream(String columnLabel) throws SQLException {
98      if (shouldThrow(this.getClass().getInterfaces()[0], "getNCharacterStream"))
99        throw new SQLException("ResultSet bombed");
100     return it.getNCharacterStream(columnLabel);
101   }
102   /** 
103    * {@inheritDoc}
104    * @see java.sql.ResultSet#getNClob(int)
105    */
106 
107   public NClob getNClob(int columnIndex) throws SQLException {
108     if (shouldThrow(this.getClass().getInterfaces()[0], "getNClob"))
109       throw new SQLException("ResultSet bombed");
110     return new ThrowingNClob(it.getNClob(columnIndex));
111   }
112   /** 
113    * {@inheritDoc}
114    * @see java.sql.ResultSet#getNClob(java.lang.String)
115    */
116 
117   public NClob getNClob(String columnLabel) throws SQLException {
118     if (shouldThrow(this.getClass().getInterfaces()[0], "getNClob"))
119       throw new SQLException("ResultSet bombed");
120     return new ThrowingNClob(it.getNClob(columnLabel));
121   }
122   /** 
123    * {@inheritDoc}
124    * @see java.sql.ResultSet#getNString(int)
125    */
126 
127   public String getNString(int columnIndex) throws SQLException {
128     if (shouldThrow(this.getClass().getInterfaces()[0], "getNString"))
129       throw new SQLException("ResultSet bombed");
130     return it.getNString(columnIndex);
131   }
132   /** 
133    * {@inheritDoc}
134    * @see java.sql.ResultSet#getNString(java.lang.String)
135    */
136 
137   public String getNString(String columnLabel) throws SQLException {
138     if (shouldThrow(this.getClass().getInterfaces()[0], "getNString"))
139       throw new SQLException("ResultSet bombed");
140     return it.getNString(columnLabel);
141   }
142   /** 
143    * {@inheritDoc}
144    * @see java.sql.ResultSet#getRowId(int)
145    */
146 
147   public RowId getRowId(int columnIndex) throws SQLException {
148     if (shouldThrow(this.getClass().getInterfaces()[0], "getRowId"))
149       throw new SQLException("ResultSet bombed");
150     return new ThrowingRowId(it.getRowId(columnIndex));
151   }
152   /** 
153    * {@inheritDoc}
154    * @see java.sql.ResultSet#getRowId(java.lang.String)
155    */
156 
157   public RowId getRowId(String columnLabel) throws SQLException {
158     if (shouldThrow(this.getClass().getInterfaces()[0], "getRowId"))
159       throw new SQLException("ResultSet bombed");
160     return new ThrowingRowId(it.getRowId(columnLabel));
161   }
162   /** 
163    * {@inheritDoc}
164    * @see java.sql.ResultSet#getSQLXML(int)
165    */
166 
167   public SQLXML getSQLXML(int columnIndex) throws SQLException {
168     if (shouldThrow(this.getClass().getInterfaces()[0], "getSQLXML"))
169       throw new SQLException("ResultSet bombed");
170     return new ThrowingSQLXML(it.getSQLXML(columnIndex));
171   }
172   /** 
173    * {@inheritDoc}
174    * @see java.sql.ResultSet#getSQLXML(java.lang.String)
175    */
176 
177   public SQLXML getSQLXML(String columnLabel) throws SQLException {
178     if (shouldThrow(this.getClass().getInterfaces()[0], "getSQLXML"))
179       throw new SQLException("ResultSet bombed");
180     return new ThrowingSQLXML(it.getSQLXML(columnLabel));
181   }
182   /** 
183    * {@inheritDoc}
184    * @see java.sql.ResultSet#isClosed()
185    */
186 
187   public boolean isClosed() throws SQLException {
188     if (shouldThrow(this.getClass().getInterfaces()[0], "isClosed"))
189       throw new SQLException("ResultSet bombed");
190     return it.isClosed();
191   }
192   /** 
193    * {@inheritDoc}
194    * @see java.sql.ResultSet#updateAsciiStream(int, java.io.InputStream, long)
195    */
196 
197   public void updateAsciiStream(int columnIndex, InputStream x, long length)
198           throws SQLException {
199     if (shouldThrow(this.getClass().getInterfaces()[0], "updateAsciiStream"))
200       throw new SQLException("ResultSet bombed");
201     it.updateAsciiStream(columnIndex, x, length);
202   }
203   /** 
204    * {@inheritDoc}
205    * @see java.sql.ResultSet#updateAsciiStream(int, java.io.InputStream)
206    */
207 
208   public void updateAsciiStream(int columnIndex, InputStream x)
209           throws SQLException {
210     if (shouldThrow(this.getClass().getInterfaces()[0], "updateAsciiStream"))
211       throw new SQLException("ResultSet bombed");
212     it.updateAsciiStream(columnIndex, x);
213   }
214   /** 
215    * {@inheritDoc}
216    * @see java.sql.ResultSet#updateAsciiStream(java.lang.String, java.io.InputStream, long)
217    */
218 
219   public void updateAsciiStream(String columnLabel, InputStream x, long length)
220           throws SQLException {
221     if (shouldThrow(this.getClass().getInterfaces()[0], "updateAsciiStream"))
222       throw new SQLException("ResultSet bombed");
223     it.updateAsciiStream(columnLabel, x, length);
224   }
225   /** 
226    * {@inheritDoc}
227    * @see java.sql.ResultSet#updateAsciiStream(java.lang.String, java.io.InputStream)
228    */
229 
230   public void updateAsciiStream(String columnLabel, InputStream x)
231           throws SQLException {
232     if (shouldThrow(this.getClass().getInterfaces()[0], "updateAsciiStream"))
233       throw new SQLException("ResultSet bombed");
234     it.updateAsciiStream(columnLabel, x);
235   }
236   /** 
237    * {@inheritDoc}
238    * @see java.sql.ResultSet#updateBinaryStream(int, java.io.InputStream, long)
239    */
240 
241   public void updateBinaryStream(int columnIndex, InputStream x, long length)
242           throws SQLException {
243     if (shouldThrow(this.getClass().getInterfaces()[0], "updateBinaryStream"))
244       throw new SQLException("ResultSet bombed");
245     it.updateBinaryStream(columnIndex, x, length);
246   }
247   /** 
248    * {@inheritDoc}
249    * @see java.sql.ResultSet#updateBinaryStream(int, java.io.InputStream)
250    */
251 
252   public void updateBinaryStream(int columnIndex, InputStream x)
253           throws SQLException {
254     if (shouldThrow(this.getClass().getInterfaces()[0], "updateBinaryStream"))
255       throw new SQLException("ResultSet bombed");
256     it.updateBinaryStream(columnIndex, x);
257   }
258   /** 
259    * {@inheritDoc}
260    * @see java.sql.ResultSet#updateBinaryStream(java.lang.String, java.io.InputStream, long)
261    */
262 
263   public void updateBinaryStream(String columnLabel, InputStream x, long length)
264           throws SQLException {
265     if (shouldThrow(this.getClass().getInterfaces()[0], "updateBinaryStream"))
266       throw new SQLException("ResultSet bombed");
267     it.updateBinaryStream(columnLabel, x, length);
268   }
269   /** 
270    * {@inheritDoc}
271    * @see java.sql.ResultSet#updateBinaryStream(java.lang.String, java.io.InputStream)
272    */
273 
274   public void updateBinaryStream(String columnLabel, InputStream x)
275           throws SQLException {
276     if (shouldThrow(this.getClass().getInterfaces()[0], "updateBinaryStream"))
277       throw new SQLException("ResultSet bombed");
278     it.updateBinaryStream(columnLabel, x);
279   }
280   /** 
281    * {@inheritDoc}
282    * @see java.sql.ResultSet#updateBlob(int, java.io.InputStream, long)
283    */
284 
285   public void updateBlob(int columnIndex, InputStream inputStream, long length)
286           throws SQLException {
287     if (shouldThrow(this.getClass().getInterfaces()[0], "updateBlob"))
288       throw new SQLException("ResultSet bombed");
289     it.updateBlob(columnIndex, inputStream, length);
290   }
291   /** 
292    * {@inheritDoc}
293    * @see java.sql.ResultSet#updateBlob(int, java.io.InputStream)
294    */
295 
296   public void updateBlob(int columnIndex, InputStream inputStream)
297           throws SQLException {
298     if (shouldThrow(this.getClass().getInterfaces()[0], "updateBlob"))
299       throw new SQLException("ResultSet bombed");
300     it.updateBlob(columnIndex, inputStream);
301   }
302   /** 
303    * {@inheritDoc}
304    * @see java.sql.ResultSet#updateBlob(java.lang.String, java.io.InputStream, long)
305    */
306 
307   public void updateBlob(String columnLabel, InputStream inputStream,
308           long length) throws SQLException {
309     if (shouldThrow(this.getClass().getInterfaces()[0], "updateBlob"))
310       throw new SQLException("ResultSet bombed");
311     it.updateBlob(columnLabel, inputStream);
312   }
313   /** 
314    * {@inheritDoc}
315    * @see java.sql.ResultSet#updateBlob(java.lang.String, java.io.InputStream)
316    */
317 
318   public void updateBlob(String columnLabel, InputStream inputStream)
319           throws SQLException {
320     if (shouldThrow(this.getClass().getInterfaces()[0], "updateBlob"))
321       throw new SQLException("ResultSet bombed");
322     it.updateBlob(columnLabel, inputStream);
323   }
324   /** 
325    * {@inheritDoc}
326    * @see java.sql.ResultSet#updateCharacterStream(int, java.io.Reader, long)
327    */
328 
329   public void updateCharacterStream(int columnIndex, Reader x, long length)
330           throws SQLException {
331     if (shouldThrow(this.getClass().getInterfaces()[0], "updateCharacterStream"))
332       throw new SQLException("ResultSet bombed");
333     it.updateCharacterStream(columnIndex, x, length);
334   }
335   /** 
336    * {@inheritDoc}
337    * @see java.sql.ResultSet#updateCharacterStream(int, java.io.Reader)
338    */
339 
340   public void updateCharacterStream(int columnIndex, Reader x)
341           throws SQLException {
342     if (shouldThrow(this.getClass().getInterfaces()[0], "updateCharacterStream"))
343       throw new SQLException("ResultSet bombed");
344     it.updateCharacterStream(columnIndex, x);
345   }
346   /** 
347    * {@inheritDoc}
348    * @see java.sql.ResultSet#updateCharacterStream(java.lang.String, java.io.Reader, long)
349    */
350 
351   public void updateCharacterStream(String columnLabel, Reader reader,
352           long length) throws SQLException {
353     if (shouldThrow(this.getClass().getInterfaces()[0], "updateCharacterStream"))
354       throw new SQLException("ResultSet bombed");
355     it.updateCharacterStream(columnLabel, reader);
356   }
357   /** 
358    * {@inheritDoc}
359    * @see java.sql.ResultSet#updateCharacterStream(java.lang.String, java.io.Reader)
360    */
361 
362   public void updateCharacterStream(String columnLabel, Reader reader)
363           throws SQLException {
364     if (shouldThrow(this.getClass().getInterfaces()[0], "updateCharacterStream"))
365       throw new SQLException("ResultSet bombed");
366     it.updateCharacterStream(columnLabel, reader);
367   }
368   /** 
369    * {@inheritDoc}
370    * @see java.sql.ResultSet#updateClob(int, java.io.Reader, long)
371    */
372 
373   public void updateClob(int columnIndex, Reader reader, long length)
374           throws SQLException {
375     if (shouldThrow(this.getClass().getInterfaces()[0], "updateClob"))
376       throw new SQLException("ResultSet bombed");
377     it.updateClob(columnIndex, reader, length);
378   }
379   /** 
380    * {@inheritDoc}
381    * @see java.sql.ResultSet#updateClob(int, java.io.Reader)
382    */
383 
384   public void updateClob(int columnIndex, Reader reader) throws SQLException {
385     if (shouldThrow(this.getClass().getInterfaces()[0], "updateClob"))
386       throw new SQLException("ResultSet bombed");
387     it.updateClob(columnIndex, reader);
388   }
389   /** 
390    * {@inheritDoc}
391    * @see java.sql.ResultSet#updateClob(java.lang.String, java.io.Reader, long)
392    */
393 
394   public void updateClob(String columnLabel, Reader reader, long length)
395           throws SQLException {
396     if (shouldThrow(this.getClass().getInterfaces()[0], "updateClob"))
397       throw new SQLException("ResultSet bombed");
398     it.updateClob(columnLabel, reader, length);
399   }
400   /** 
401    * {@inheritDoc}
402    * @see java.sql.ResultSet#updateClob(java.lang.String, java.io.Reader)
403    */
404 
405   public void updateClob(String columnLabel, Reader reader) throws SQLException {
406     if (shouldThrow(this.getClass().getInterfaces()[0], "updateClob"))
407       throw new SQLException("ResultSet bombed");
408     it.updateClob(columnLabel, reader);
409   }
410   /** 
411    * {@inheritDoc}
412    * @see java.sql.ResultSet#updateNCharacterStream(int, java.io.Reader, long)
413    */
414 
415   public void updateNCharacterStream(int columnIndex, Reader x, long length)
416           throws SQLException {
417     if (shouldThrow(this.getClass().getInterfaces()[0], "updateNCharacterStream"))
418       throw new SQLException("ResultSet bombed");
419     it.updateNCharacterStream(columnIndex, x, length);
420   }
421   /** 
422    * {@inheritDoc}
423    * @see java.sql.ResultSet#updateNCharacterStream(int, java.io.Reader)
424    */
425 
426   public void updateNCharacterStream(int columnIndex, Reader x)
427           throws SQLException {
428     if (shouldThrow(this.getClass().getInterfaces()[0], "updateNCharacterStream"))
429       throw new SQLException("ResultSet bombed");
430     it.updateNCharacterStream(columnIndex, x);
431   }
432   /** 
433    * {@inheritDoc}
434    * @see java.sql.ResultSet#updateNCharacterStream(java.lang.String, java.io.Reader, long)
435    */
436 
437   public void updateNCharacterStream(String columnLabel, Reader reader,
438           long length) throws SQLException {
439     if (shouldThrow(this.getClass().getInterfaces()[0], "updateNCharacterStream"))
440       throw new SQLException("ResultSet bombed");
441     it.updateNCharacterStream(columnLabel, reader);
442   }
443   /** 
444    * {@inheritDoc}
445    * @see java.sql.ResultSet#updateNCharacterStream(java.lang.String, java.io.Reader)
446    */
447 
448   public void updateNCharacterStream(String columnLabel, Reader reader)
449           throws SQLException {
450     if (shouldThrow(this.getClass().getInterfaces()[0], "updateNCharacterStream"))
451       throw new SQLException("ResultSet bombed");
452     it.updateNCharacterStream(columnLabel, reader);
453   }
454   /** 
455    * {@inheritDoc}
456    * @see java.sql.ResultSet#updateNClob(int, java.sql.NClob)
457    */
458 
459   public void updateNClob(int columnIndex, NClob clob) throws SQLException {
460     if (shouldThrow(this.getClass().getInterfaces()[0], "updateNClob"))
461       throw new SQLException("ResultSet bombed");
462     it.updateNClob(columnIndex, clob);
463   }
464   /** 
465    * {@inheritDoc}
466    * @see java.sql.ResultSet#updateNClob(int, java.io.Reader, long)
467    */
468 
469   public void updateNClob(int columnIndex, Reader reader, long length)
470           throws SQLException {
471     if (shouldThrow(this.getClass().getInterfaces()[0], "updateNClob"))
472       throw new SQLException("ResultSet bombed");
473     it.updateNClob(columnIndex, reader, length);
474   }
475   /** 
476    * {@inheritDoc}
477    * @see java.sql.ResultSet#updateNClob(int, java.io.Reader)
478    */
479 
480   public void updateNClob(int columnIndex, Reader reader) throws SQLException {
481     if (shouldThrow(this.getClass().getInterfaces()[0], "updateNClob"))
482       throw new SQLException("ResultSet bombed");
483     it.updateNClob(columnIndex, reader);
484   }
485   /** 
486    * {@inheritDoc}
487    * @see java.sql.ResultSet#updateNClob(java.lang.String, java.sql.NClob)
488    */
489 
490   public void updateNClob(String columnLabel, NClob clob) throws SQLException {
491     if (shouldThrow(this.getClass().getInterfaces()[0], "updateNClob"))
492       throw new SQLException("ResultSet bombed");
493     it.updateNClob(columnLabel, clob);
494   }
495   /** 
496    * {@inheritDoc}
497    * @see java.sql.ResultSet#updateNClob(java.lang.String, java.io.Reader, long)
498    */
499 
500   public void updateNClob(String columnLabel, Reader reader, long length)
501           throws SQLException {
502     if (shouldThrow(this.getClass().getInterfaces()[0], "updateNClob"))
503       throw new SQLException("ResultSet bombed");
504     it.updateNClob(columnLabel, reader, length);
505   }
506   /** 
507    * {@inheritDoc}
508    * @see java.sql.ResultSet#updateNClob(java.lang.String, java.io.Reader)
509    */
510 
511   public void updateNClob(String columnLabel, Reader reader)
512           throws SQLException {
513     if (shouldThrow(this.getClass().getInterfaces()[0], "updateNClob"))
514       throw new SQLException("ResultSet bombed");
515     it.updateNClob(columnLabel, reader);
516   }
517   /** 
518    * {@inheritDoc}
519    * @see java.sql.ResultSet#updateNString(int, java.lang.String)
520    */
521 
522   public void updateNString(int columnIndex, String string) throws SQLException {
523     if (shouldThrow(this.getClass().getInterfaces()[0], "updateNString"))
524       throw new SQLException("ResultSet bombed");
525     it.updateNString(columnIndex, string);
526   }
527   /** 
528    * {@inheritDoc}
529    * @see java.sql.ResultSet#updateNString(java.lang.String, java.lang.String)
530    */
531 
532   public void updateNString(String columnLabel, String string)
533           throws SQLException {
534     if (shouldThrow(this.getClass().getInterfaces()[0], "updateNString"))
535       throw new SQLException("ResultSet bombed");
536     it.updateNString(columnLabel, string);
537   }
538   /** 
539    * {@inheritDoc}
540    * @see java.sql.ResultSet#updateRowId(int, java.sql.RowId)
541    */
542 
543   public void updateRowId(int columnIndex, RowId x) throws SQLException {
544     if (shouldThrow(this.getClass().getInterfaces()[0], "updateRowId"))
545       throw new SQLException("ResultSet bombed");
546     it.updateRowId(columnIndex, x);
547   }
548   /** 
549    * {@inheritDoc}
550    * @see java.sql.ResultSet#updateRowId(java.lang.String, java.sql.RowId)
551    */
552 
553   public void updateRowId(String columnLabel, RowId x) throws SQLException {
554     if (shouldThrow(this.getClass().getInterfaces()[0], "updateRowId"))
555       throw new SQLException("ResultSet bombed");
556     it.updateRowId(columnLabel, x);
557   }
558   /** 
559    * {@inheritDoc}
560    * @see java.sql.ResultSet#updateSQLXML(int, java.sql.SQLXML)
561    */
562 
563   public void updateSQLXML(int columnIndex, SQLXML xmlObject)
564           throws SQLException {
565     if (shouldThrow(this.getClass().getInterfaces()[0], "updateSQLXML"))
566       throw new SQLException("ResultSet bombed");
567     it.updateSQLXML(columnIndex, xmlObject);
568   }
569   /** 
570    * {@inheritDoc}
571    * @see java.sql.ResultSet#updateSQLXML(java.lang.String, java.sql.SQLXML)
572    */
573 
574   public void updateSQLXML(String columnLabel, SQLXML xmlObject)
575           throws SQLException {
576     if (shouldThrow(this.getClass().getInterfaces()[0], "updateSQLXML"))
577       throw new SQLException("ResultSet bombed");
578     it.updateSQLXML(columnLabel, xmlObject);
579   }
580   /** 
581    * {@inheritDoc}
582    * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)
583    */
584 
585   public boolean isWrapperFor(Class<?> iface) throws SQLException {
586     if (shouldThrow(this.getClass().getInterfaces()[0], "isWrapperFor"))
587       throw new SQLException("ResultSet bombed");
588     return it.isWrapperFor(iface);
589   }
590   /** 
591    * {@inheritDoc}
592    * @see java.sql.Wrapper#unwrap(java.lang.Class)
593    */
594 
595   public <T1> T1 unwrap(Class<T1> iface) throws SQLException {
596     if (shouldThrow(this.getClass().getInterfaces()[0], "unwrap"))
597       throw new SQLException("ResultSet bombed");
598     return it.unwrap(iface);
599   }
600 
601 
602 }