View Javadoc

1   /*
2    * $Source: /usr/cvsroot/melati/throwing-jdbc/src/main/java/org/melati/poem/dbms/test/sql/ThrowingArrayJdbc3.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.Array;
48  import java.sql.ResultSet;
49  import java.sql.SQLException;
50  import java.util.Map;
51  
52  /**
53   * The JDBC 3 members of an {@link Array}, decorated to throw an SQLException on command.
54   * 
55   * @author timp
56   * @since  5 Feb 2008
57   *
58   */
59  public abstract class ThrowingArrayJdbc3 
60      extends Thrower 
61      implements Array {
62  
63    Array it = null;
64  
65  
66    /** 
67     * {@inheritDoc}
68     * @see java.sql.Array#getArray()
69     */
70    public Object getArray() throws SQLException {
71      if (shouldThrow(this.getClass().getInterfaces()[0], "getArray"))
72        throw new SQLException("Array bombed");
73      return it.getArray();
74    }
75  
76    /** 
77     * {@inheritDoc}
78     * @see java.sql.Array#getArray(java.util.Map)
79     */
80    public Object getArray(Map map) throws SQLException {
81      if (shouldThrow(this.getClass().getInterfaces()[0], "getArray"))
82        throw new SQLException("Array bombed");
83      return it.getArray();
84    }
85  
86    /** 
87     * {@inheritDoc}
88     * @see java.sql.Array#getArray(long, int)
89     */
90    public Object getArray(long index, int count) throws SQLException {
91      if (shouldThrow(this.getClass().getInterfaces()[0], "getArray"))
92        throw new SQLException("Array bombed");
93      return it.getArray();
94    }
95  
96    /** 
97     * {@inheritDoc}
98     * @see java.sql.Array#getArray(long, int, java.util.Map)
99     */
100   public Object getArray(long index, int count, Map map)
101           throws SQLException {
102     if (shouldThrow(this.getClass().getInterfaces()[0], "getArray"))
103       throw new SQLException("Array bombed");
104     return it.getArray();
105   }
106 
107   /** 
108    * {@inheritDoc}
109    * @see java.sql.Array#getBaseType()
110    */
111   public int getBaseType() throws SQLException {
112     if (shouldThrow(this.getClass().getInterfaces()[0], "getBaseType"))
113       throw new SQLException("Array bombed");
114     return it.getBaseType();
115   }
116 
117   /** 
118    * {@inheritDoc}
119    * @see java.sql.Array#getBaseTypeName()
120    */
121   public String getBaseTypeName() throws SQLException {
122     if (shouldThrow(this.getClass().getInterfaces()[0], "getBaseTypeName"))
123       throw new SQLException("Array bombed");
124     return it.getBaseTypeName();
125   }
126 
127   /** 
128    * {@inheritDoc}
129    * @see java.sql.Array#getResultSet()
130    */
131   public ResultSet getResultSet() throws SQLException {
132     if (shouldThrow(this.getClass().getInterfaces()[0], "getResultSet"))
133       throw new SQLException("Array bombed");
134     return new ThrowingResultSet(it.getResultSet());
135   }
136 
137   /** 
138    * {@inheritDoc}
139    * @see java.sql.Array#getResultSet(java.util.Map)
140    */
141   public ResultSet getResultSet(Map map) throws SQLException {
142     if (shouldThrow(this.getClass().getInterfaces()[0], "getResultSet"))
143       throw new SQLException("Array bombed");
144     return  new ThrowingResultSet(it.getResultSet());
145   }
146 
147   /** 
148    * {@inheritDoc}
149    * @see java.sql.Array#getResultSet(long, int)
150    */
151   public ResultSet getResultSet(long index, int count) throws SQLException {
152     if (shouldThrow(this.getClass().getInterfaces()[0], "getResultSet"))
153       throw new SQLException("Array bombed");
154     return  new ThrowingResultSet(it.getResultSet());
155   }
156 
157   /** 
158    * {@inheritDoc}
159    * @see java.sql.Array#getResultSet(long, int, java.util.Map)
160    */
161   public ResultSet getResultSet(long index, int count, Map map)
162           throws SQLException {
163     if (shouldThrow(this.getClass().getInterfaces()[0], "getResultSet"))
164       throw new SQLException("Array bombed");
165     return  new ThrowingResultSet(it.getResultSet());
166   }
167 
168   
169 }