KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > extractor > sql > RuntimeVarInfo


1 /*
2  * This file belongs to the XQuark distribution.
3  * Copyright (C) 2003 XQuark Group.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307.
18  * You can also get it at http://www.gnu.org/licenses/lgpl.html
19  *
20  * For more information on this software, see http://www.xquark.org.
21  */

22
23 package org.xquark.extractor.sql;
24
25 import java.io.InputStream JavaDoc;
26 import java.math.BigDecimal JavaDoc;
27 import java.sql.PreparedStatement JavaDoc;
28 import java.sql.SQLException JavaDoc;
29 import java.sql.Timestamp JavaDoc;
30 import java.util.Date JavaDoc;
31
32 import org.xquark.schema.SchemaException;
33
34 /**
35  * Data structure containing JDBC prepared statement parameter info.
36  */

37 public class RuntimeVarInfo {
38     
39     public PlaceHolderInfo compiledVarInfo = null;
40     public PreparedStatement JavaDoc pStmt = null;
41     
42     public RuntimeVarInfo(PlaceHolderInfo varInfo, PreparedStatement JavaDoc pStmt) {
43         compiledVarInfo = varInfo;
44         this.pStmt = pStmt;
45     }
46     
47     public void setParameter(String JavaDoc value) throws SQLException JavaDoc, SchemaException {
48         if (compiledVarInfo.mappingInfo == null)
49             pStmt.setString(compiledVarInfo.index, value);
50         else
51             compiledVarInfo.mappingInfo.setParameter(pStmt, compiledVarInfo.index, value);
52     }
53     
54     public void setObject(Object JavaDoc value) throws SQLException JavaDoc {
55         pStmt.setObject(compiledVarInfo.index, value);
56     }
57
58     public void setBigDecimal(BigDecimal JavaDoc decimal) throws SQLException JavaDoc {
59         pStmt.setBigDecimal(compiledVarInfo.index, decimal);
60     }
61
62     public void setInputStream(InputStream JavaDoc stream, int size) throws SQLException JavaDoc {
63         pStmt.setBinaryStream(compiledVarInfo.index, stream, size);
64     }
65
66     public void setBytes(byte[] bytes) throws SQLException JavaDoc {
67         pStmt.setBytes(compiledVarInfo.index, bytes);
68     }
69
70     public void setBoolean(boolean bool) throws SQLException JavaDoc {
71         pStmt.setBoolean(compiledVarInfo.index, bool);
72     }
73
74     public void setDate(Date JavaDoc date) throws SQLException JavaDoc {
75         pStmt.setTimestamp(compiledVarInfo.index, new Timestamp JavaDoc(date.getTime()));
76     }
77
78     public void setFloat(float f) throws SQLException JavaDoc {
79         pStmt.setFloat(compiledVarInfo.index, f);
80     }
81
82     public void setDouble(double d) throws SQLException JavaDoc {
83         pStmt.setDouble(compiledVarInfo.index, d);
84     }
85
86     public void setLong(long l) throws SQLException JavaDoc {
87         pStmt.setLong(compiledVarInfo.index, l);
88     }
89     
90     public void setString(String JavaDoc s) throws SQLException JavaDoc {
91         pStmt.setString(compiledVarInfo.index, s);
92     }
93 }
94
Popular Tags