View Javadoc

1   /*
2    * $Source: /usr/cvsroot/melati/throwing-jdbc/src/main/java/org/melati/poem/dbms/test/sql/ThrowingResultSetMetaDataJdbc3.java,v $
3    * $Revision: 1.3 $
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.sql.ResultSetMetaData;
48  import java.sql.SQLException;
49  
50  /**
51   * The JDBC3 methods of a {@link ResultSetMetaData}, decorated to throw an {@SQLException} on command.
52   * 
53   * @author timp
54   * @since  5 Feb 2008
55   *
56   */
57  public abstract class ThrowingResultSetMetaDataJdbc3 extends Thrower implements ResultSetMetaData {
58  
59    ResultSetMetaData it = null;
60  
61    public String getCatalogName(int column) throws SQLException {
62      if (shouldThrow(this.getClass().getInterfaces()[0], "getCatalogName"))
63        throw new SQLException("ResultSetMetaData bombed");
64      return it.getCatalogName(column);
65    }
66  
67    public String getColumnClassName(int column) throws SQLException {
68      if (shouldThrow(this.getClass().getInterfaces()[0], "getColumnClassName"))
69        throw new SQLException("ResultSetMetaData bombed");
70      return it.getColumnClassName(column);
71    }
72  
73    public int getColumnCount() throws SQLException {
74      if (shouldThrow(this.getClass().getInterfaces()[0], "getColumnCount"))
75        throw new SQLException("ResultSetMetaData bombed");
76      return it.getColumnCount();
77    }
78  
79    public int getColumnDisplaySize(int column) throws SQLException {
80      if (shouldThrow(this.getClass().getInterfaces()[0], "getColumnDisplaySize"))
81        throw new SQLException("ResultSetMetaData bombed");
82      return it.getColumnDisplaySize(column);
83    }
84  
85    public String getColumnLabel(int column) throws SQLException {
86      if (shouldThrow(this.getClass().getInterfaces()[0], "getColumnLabel"))
87        throw new SQLException("ResultSetMetaData bombed");
88      return it.getColumnLabel(column);
89    }
90  
91    public String getColumnName(int column) throws SQLException {
92      if (shouldThrow(this.getClass().getInterfaces()[0], "getColumnName"))
93        throw new SQLException("ResultSetMetaData bombed");
94      return it.getColumnName(column);
95    }
96  
97    public int getColumnType(int column) throws SQLException {
98      if (shouldThrow(this.getClass().getInterfaces()[0], "getColumnType"))
99        throw new SQLException("ResultSetMetaData bombed");
100     return it.getColumnType(column);
101   }
102 
103   public String getColumnTypeName(int column) throws SQLException {
104     if (shouldThrow(this.getClass().getInterfaces()[0], "getColumnTypeName"))
105       throw new SQLException("ResultSetMetaData bombed");
106     return it.getColumnTypeName(column);
107  }
108 
109   public int getPrecision(int column) throws SQLException {
110     if (shouldThrow(this.getClass().getInterfaces()[0], "getPrecision"))
111       throw new SQLException("ResultSetMetaData bombed");
112     return it.getPrecision(column);
113   }
114 
115   public int getScale(int column) throws SQLException {
116     if (shouldThrow(this.getClass().getInterfaces()[0], "getScale"))
117       throw new SQLException("ResultSetMetaData bombed");
118     return it.getScale(column);
119   }
120 
121   public String getSchemaName(int column) throws SQLException {
122     if (shouldThrow(this.getClass().getInterfaces()[0], "getSchemaName"))
123       throw new SQLException("ResultSetMetaData bombed");
124     return it.getSchemaName(column);
125   }
126 
127   public String getTableName(int column) throws SQLException {
128     if (shouldThrow(this.getClass().getInterfaces()[0], "getTableName"))
129       throw new SQLException("ResultSetMetaData bombed");
130     return it.getTableName(column);
131   }
132 
133   public boolean isAutoIncrement(int column) throws SQLException {
134     if (shouldThrow(this.getClass().getInterfaces()[0], "isAutoIncrement"))
135       throw new SQLException("ResultSetMetaData bombed");
136     return it.isAutoIncrement(column);
137   }
138 
139   public boolean isCaseSensitive(int column) throws SQLException {
140     if (shouldThrow(this.getClass().getInterfaces()[0], "isCaseSensitive"))
141       throw new SQLException("ResultSetMetaData bombed");
142     return it.isCaseSensitive(column);
143   }
144 
145   public boolean isCurrency(int column) throws SQLException {
146     if (shouldThrow(this.getClass().getInterfaces()[0], "isCurrency"))
147       throw new SQLException("ResultSetMetaData bombed");
148     return it.isCurrency(column);
149   }
150 
151   public boolean isDefinitelyWritable(int column) throws SQLException {
152     if (shouldThrow(this.getClass().getInterfaces()[0], "isDefinitelyWritable"))
153       throw new SQLException("ResultSetMetaData bombed");
154     return it.isDefinitelyWritable(column);
155   }
156 
157   public int isNullable(int column) throws SQLException {
158     if (shouldThrow(this.getClass().getInterfaces()[0], "isNullable"))
159       throw new SQLException("ResultSetMetaData bombed");
160     return it.isNullable(column);
161   }
162 
163   public boolean isReadOnly(int column) throws SQLException {
164     if (shouldThrow(this.getClass().getInterfaces()[0], "isReadOnly"))
165       throw new SQLException("ResultSetMetaData bombed");
166     return it.isReadOnly(column);
167   }
168 
169   public boolean isSearchable(int column) throws SQLException {
170     if (shouldThrow(this.getClass().getInterfaces()[0], "isSearchable"))
171       throw new SQLException("ResultSetMetaData bombed");
172     return it.isSearchable(column);
173   }
174 
175   public boolean isSigned(int column) throws SQLException {
176     if (shouldThrow(this.getClass().getInterfaces()[0], "isSigned"))
177       throw new SQLException("ResultSetMetaData bombed");
178     return it.isSigned(column);
179   }
180 
181   public boolean isWritable(int column) throws SQLException {
182     if (shouldThrow(this.getClass().getInterfaces()[0], "isWritable"))
183       throw new SQLException("ResultSetMetaData bombed");
184     return it.isWritable(column);
185   }
186 }