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.RowId;
51  import java.sql.PreparedStatement;
52  import java.sql.SQLException;
53  import java.sql.SQLXML;
54  
55  /**
56   * The JDBC4 members of a {@link PreparedStatement}, decorated to throw an SQLException on command.
57   * 
58   * @author timp
59   * @since  5 Feb 2008
60   *
61   */
62  public abstract class ThrowingPreparedStatementJdbc4 
63      extends ThrowingPreparedStatementJdbc3 
64      implements PreparedStatement {
65  
66    
67    /**
68     *  JDBC 4.0
69     */
70    
71    /** 
72     * {@inheritDoc}
73     * @see java.sql.PreparedStatement#setAsciiStream(int, java.io.InputStream, long)
74     */
75  
76    public void setAsciiStream(int parameterIndex, InputStream x, long length)
77            throws SQLException {
78      if (shouldThrow(this.getClass().getInterfaces()[0], "setAsciiStream"))
79        throw new SQLException("PreparedStatement bombed");
80      it.setAsciiStream(parameterIndex, x, length);
81    }
82    /** 
83     * {@inheritDoc}
84     * @see java.sql.PreparedStatement#setAsciiStream(int, java.io.InputStream)
85     */
86  
87    public void setAsciiStream(int parameterIndex, InputStream x)
88            throws SQLException {
89      if (shouldThrow(this.getClass().getInterfaces()[0], "setAsciiStream"))
90        throw new SQLException("PreparedStatement bombed");
91      it.setAsciiStream(parameterIndex, x);
92    }
93    /** 
94     * {@inheritDoc}
95     * @see java.sql.PreparedStatement#setBinaryStream(int, java.io.InputStream, long)
96     */
97  
98    public void setBinaryStream(int parameterIndex, InputStream x, long length)
99            throws SQLException {
100     if (shouldThrow(this.getClass().getInterfaces()[0], "setBinaryStream"))
101       throw new SQLException("PreparedStatement bombed");
102     it.setBinaryStream(parameterIndex, x, length);
103   }
104   /** 
105    * {@inheritDoc}
106    * @see java.sql.PreparedStatement#setBinaryStream(int, java.io.InputStream)
107    */
108 
109   public void setBinaryStream(int parameterIndex, InputStream x)
110           throws SQLException {
111     if (shouldThrow(this.getClass().getInterfaces()[0], "setBinaryStream"))
112       throw new SQLException("PreparedStatement bombed");
113     it.setBinaryStream(parameterIndex, x);
114   }
115   /** 
116    * {@inheritDoc}
117    * @see java.sql.PreparedStatement#setBlob(int, java.io.InputStream, long)
118    */
119 
120   public void setBlob(int parameterIndex, InputStream inputStream, long length)
121           throws SQLException {
122     if (shouldThrow(this.getClass().getInterfaces()[0], "setBlob"))
123       throw new SQLException("PreparedStatement bombed");
124     it.setBlob(parameterIndex, inputStream, length);
125   }
126   /** 
127    * {@inheritDoc}
128    * @see java.sql.PreparedStatement#setBlob(int, java.io.InputStream)
129    */
130 
131   public void setBlob(int parameterIndex, InputStream inputStream)
132           throws SQLException {
133     if (shouldThrow(this.getClass().getInterfaces()[0], "setBlob"))
134       throw new SQLException("PreparedStatement bombed");
135     it.setBlob(parameterIndex, inputStream);
136   }
137   /** 
138    * {@inheritDoc}
139    * @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader, long)
140    */
141 
142   public void setCharacterStream(int parameterIndex, Reader reader, long length)
143           throws SQLException {
144     if (shouldThrow(this.getClass().getInterfaces()[0], "setCharacterStream"))
145       throw new SQLException("PreparedStatement bombed");
146     it.setCharacterStream(parameterIndex, reader, length);
147   }
148   /** 
149    * {@inheritDoc}
150    * @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader)
151    */
152 
153   public void setCharacterStream(int parameterIndex, Reader reader)
154           throws SQLException {
155     if (shouldThrow(this.getClass().getInterfaces()[0], "setCharacterStream"))
156       throw new SQLException("PreparedStatement bombed");
157     it.setCharacterStream(parameterIndex, reader);
158   }
159   /** 
160    * {@inheritDoc}
161    * @see java.sql.PreparedStatement#setClob(int, java.io.Reader, long)
162    */
163 
164   public void setClob(int parameterIndex, Reader reader, long length)
165           throws SQLException {
166     if (shouldThrow(this.getClass().getInterfaces()[0], "setClob"))
167       throw new SQLException("PreparedStatement bombed");
168     it.setClob(parameterIndex, reader, length);
169   }
170   /** 
171    * {@inheritDoc}
172    * @see java.sql.PreparedStatement#setClob(int, java.io.Reader)
173    */
174 
175   public void setClob(int parameterIndex, Reader reader) throws SQLException {
176     if (shouldThrow(this.getClass().getInterfaces()[0], "setClob"))
177       throw new SQLException("PreparedStatement bombed");
178     it.setClob(parameterIndex, reader);
179   }
180   /** 
181    * {@inheritDoc}
182    * @see java.sql.PreparedStatement#setNCharacterStream(int, java.io.Reader, long)
183    */
184 
185   public void setNCharacterStream(int parameterIndex, Reader value, long length)
186           throws SQLException {
187     if (shouldThrow(this.getClass().getInterfaces()[0], "setNCharacterStream"))
188       throw new SQLException("PreparedStatement bombed");
189     it.setNCharacterStream(parameterIndex, value, length);
190   }
191   /** 
192    * {@inheritDoc}
193    * @see java.sql.PreparedStatement#setNCharacterStream(int, java.io.Reader)
194    */
195 
196   public void setNCharacterStream(int parameterIndex, Reader value)
197           throws SQLException {
198     if (shouldThrow(this.getClass().getInterfaces()[0], "setNCharacterStream"))
199       throw new SQLException("PreparedStatement bombed");
200     it.setNCharacterStream(parameterIndex, value);
201   }
202   /** 
203    * {@inheritDoc}
204    * @see java.sql.PreparedStatement#setNClob(int, java.sql.NClob)
205    */
206 
207   public void setNClob(int parameterIndex, NClob value) throws SQLException {
208     if (shouldThrow(this.getClass().getInterfaces()[0], "setNClob"))
209       throw new SQLException("PreparedStatement bombed");
210     it.setNClob(parameterIndex, value);
211   }
212   /** 
213    * {@inheritDoc}
214    * @see java.sql.PreparedStatement#setNClob(int, java.io.Reader, long)
215    */
216 
217   public void setNClob(int parameterIndex, Reader reader, long length)
218           throws SQLException {
219     if (shouldThrow(this.getClass().getInterfaces()[0], "setNClob"))
220       throw new SQLException("PreparedStatement bombed");
221     it.setNClob(parameterIndex, reader, length);
222   }
223   /** 
224    * {@inheritDoc}
225    * @see java.sql.PreparedStatement#setNClob(int, java.io.Reader)
226    */
227 
228   public void setNClob(int parameterIndex, Reader reader) throws SQLException {
229     if (shouldThrow(this.getClass().getInterfaces()[0], "setNClob"))
230       throw new SQLException("PreparedStatement bombed");
231     it.setNClob(parameterIndex, reader);
232   }
233   /** 
234    * {@inheritDoc}
235    * @see java.sql.PreparedStatement#setNString(int, java.lang.String)
236    */
237 
238   public void setNString(int parameterIndex, String value) throws SQLException {
239     if (shouldThrow(this.getClass().getInterfaces()[0], "setNString"))
240       throw new SQLException("PreparedStatement bombed");
241     it.setNString(parameterIndex, value);
242   }
243   /** 
244    * {@inheritDoc}
245    * @see java.sql.PreparedStatement#setRowId(int, java.sql.RowId)
246    */
247 
248   public void setRowId(int parameterIndex, RowId x) throws SQLException {
249     if (shouldThrow(this.getClass().getInterfaces()[0], "setRowId"))
250       throw new SQLException("PreparedStatement bombed");
251     it.setRowId(parameterIndex, x);
252   }
253   /** 
254    * {@inheritDoc}
255    * @see java.sql.PreparedStatement#setSQLXML(int, java.sql.SQLXML)
256    */
257 
258   public void setSQLXML(int parameterIndex, SQLXML xmlObject)
259           throws SQLException {
260     if (shouldThrow(this.getClass().getInterfaces()[0], "setSQLXML"))
261       throw new SQLException("PreparedStatement bombed");
262     it.setSQLXML(parameterIndex, xmlObject);
263   }
264   /** 
265    * {@inheritDoc}
266    * @see java.sql.Statement#isClosed()
267    */
268 
269   public boolean isClosed() throws SQLException {
270     if (shouldThrow(this.getClass().getInterfaces()[0], "isClosed"))
271       throw new SQLException("PreparedStatement bombed");
272     return it.isClosed();
273   }
274   /** 
275    * {@inheritDoc}
276    * @see java.sql.Statement#isPoolable()
277    */
278 
279   public boolean isPoolable() throws SQLException {
280     if (shouldThrow(this.getClass().getInterfaces()[0], "isPoolable"))
281       throw new SQLException("PreparedStatement bombed");
282     return it.isPoolable();
283   }
284   /** 
285    * {@inheritDoc}
286    * @see java.sql.Statement#setPoolable(boolean)
287    */
288 
289   public void setPoolable(boolean poolable) throws SQLException {
290     if (shouldThrow(this.getClass().getInterfaces()[0], "setPoolable"))
291       throw new SQLException("PreparedStatement bombed");
292     it.setPoolable(poolable);
293   }
294   /** 
295    * {@inheritDoc}
296    * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)
297    */
298 
299   public boolean isWrapperFor(Class<?> iface) throws SQLException {
300     if (shouldThrow(this.getClass().getInterfaces()[0], "isWrapperFor"))
301       throw new SQLException("PreparedStatement bombed");
302     return it.isWrapperFor(iface);
303   }
304   /** 
305    * {@inheritDoc}
306    * @see java.sql.Wrapper#unwrap(java.lang.Class)
307    */
308 
309   public <T> T unwrap(Class<T> iface) throws SQLException {
310     if (shouldThrow(this.getClass().getInterfaces()[0], "unwrap"))
311       throw new SQLException("PreparedStatement bombed");
312     return it.unwrap(iface);
313   }
314   
315 
316   
317   
318 }