View Javadoc
1   /*
2    * Copyright 2004-2022 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    https://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package com.ibatis.sqlmap.engine.type;
17  
18  import com.ibatis.sqlmap.client.extensions.ParameterSetter;
19  
20  import java.io.InputStream;
21  import java.io.Reader;
22  import java.math.BigDecimal;
23  import java.net.URL;
24  import java.sql.*;
25  import java.util.Calendar;
26  
27  /**
28   * A ParameterSetter implementation.
29   */
30  public class ParameterSetterImpl implements ParameterSetter {
31  
32    /** The ps. */
33    private PreparedStatement ps;
34  
35    /** The index. */
36    private int index;
37  
38    /**
39     * Creates an instance for a PreparedStatement and column index.
40     *
41     * @param statement
42     *          - the PreparedStatement
43     * @param columnIndex
44     *          - the column index
45     */
46    public ParameterSetterImpl(PreparedStatement statement, int columnIndex) {
47      this.ps = statement;
48      this.index = columnIndex;
49    }
50  
51    public void setArray(Array x) throws SQLException {
52      ps.setArray(index, x);
53    }
54  
55    public void setAsciiStream(InputStream x, int length) throws SQLException {
56      ps.setAsciiStream(index, x, length);
57    }
58  
59    public void setBigDecimal(BigDecimal x) throws SQLException {
60      ps.setBigDecimal(index, x);
61    }
62  
63    public void setBinaryStream(InputStream x, int length) throws SQLException {
64      ps.setBinaryStream(index, x, length);
65    }
66  
67    public void setBlob(Blob x) throws SQLException {
68      ps.setBlob(index, x);
69    }
70  
71    public void setBoolean(boolean x) throws SQLException {
72      ps.setBoolean(index, x);
73    }
74  
75    public void setByte(byte x) throws SQLException {
76      ps.setByte(index, x);
77    }
78  
79    public void setBytes(byte x[]) throws SQLException {
80      ps.setBytes(index, x);
81    }
82  
83    public void setCharacterStream(Reader reader, int length) throws SQLException {
84      ps.setCharacterStream(index, reader, length);
85    }
86  
87    public void setClob(Clob x) throws SQLException {
88      ps.setClob(index, x);
89    }
90  
91    public void setDate(Date x) throws SQLException {
92      ps.setDate(index, x);
93    }
94  
95    public void setDate(Date x, Calendar cal) throws SQLException {
96      ps.setDate(index, x, cal);
97    }
98  
99    public void setDouble(double x) throws SQLException {
100     ps.setDouble(index, x);
101   }
102 
103   public void setFloat(float x) throws SQLException {
104     ps.setFloat(index, x);
105   }
106 
107   public void setInt(int x) throws SQLException {
108     ps.setInt(index, x);
109   }
110 
111   public void setLong(long x) throws SQLException {
112     ps.setLong(index, x);
113   }
114 
115   public void setNull(int sqlType) throws SQLException {
116     ps.setNull(index, sqlType);
117   }
118 
119   public void setNull(int sqlType, String typeName) throws SQLException {
120     ps.setNull(index, sqlType, typeName);
121   }
122 
123   public void setObject(Object x) throws SQLException {
124     ps.setObject(index, x);
125   }
126 
127   public void setObject(Object x, int targetSqlType) throws SQLException {
128     ps.setObject(index, x, targetSqlType);
129   }
130 
131   public void setObject(Object x, int targetSqlType, int scale) throws SQLException {
132     ps.setObject(index, x, scale);
133   }
134 
135   public void setRef(Ref x) throws SQLException {
136     ps.setRef(index, x);
137   }
138 
139   public void setShort(short x) throws SQLException {
140     ps.setShort(index, x);
141   }
142 
143   public void setString(String x) throws SQLException {
144     ps.setString(index, x);
145   }
146 
147   public void setTime(Time x) throws SQLException {
148     ps.setTime(index, x);
149   }
150 
151   public void setTime(Time x, Calendar cal) throws SQLException {
152     ps.setTime(index, x, cal);
153   }
154 
155   public void setTimestamp(Timestamp x) throws SQLException {
156     ps.setTimestamp(index, x);
157   }
158 
159   public void setTimestamp(Timestamp x, Calendar cal) throws SQLException {
160     ps.setTimestamp(index, x, cal);
161   }
162 
163   public void setURL(URL x) throws SQLException {
164     ps.setURL(index, x);
165   }
166 
167   public PreparedStatement getPreparedStatement() {
168     return ps;
169   }
170 
171   public int getParameterIndex() {
172     return index;
173   }
174 }