KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > internal > databaseaccess > InOutputParameterForCallableStatement


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2005, Oracle. All rights reserved.
22
package oracle.toplink.essentials.internal.databaseaccess;
23
24 import java.sql.*;
25 import oracle.toplink.essentials.internal.helper.DatabaseField;
26 import oracle.toplink.essentials.internal.sessions.AbstractSession;
27
28 public class InOutputParameterForCallableStatement extends OutputParameterForCallableStatement {
29     protected Object JavaDoc inParameter;
30
31     public InOutputParameterForCallableStatement(Object JavaDoc inParameter, OutputParameterForCallableStatement outParameter) {
32         super(outParameter);
33         if (inParameter == null) {
34             this.inParameter = getOutputField();
35         } else {
36             this.inParameter = inParameter;
37         }
38     }
39
40     public InOutputParameterForCallableStatement(Object JavaDoc inParameter, DatabaseField outField, DatabasePlatform platform) {
41         if ((outField.getType() == null) && (inParameter != null)) {
42             DatabaseField typeField = (DatabaseField)outField.clone();
43             if (inParameter instanceof DatabaseField) {
44                 typeField.setType(((DatabaseField)inParameter).getType());
45             } else {
46                 typeField.setType(inParameter.getClass());
47             }
48             outField = typeField;
49         }
50         obj = outField;
51         prepare(platform);
52         if (inParameter == null) {
53             this.inParameter = getOutputField();
54         } else {
55             this.inParameter = inParameter;
56         }
57     }
58
59     public void set(DatabasePlatform platform, PreparedStatement statement, int index, AbstractSession session) throws SQLException {
60         platform.setParameterValueInDatabaseCall(inParameter, statement, index, session);
61         super.set(platform, statement, index, session);
62     }
63
64     public String JavaDoc toString() {
65         String JavaDoc strIn;
66         if (inParameter instanceof DatabaseField) {
67             strIn = "null";
68         } else {
69             strIn = inParameter.toString();
70         }
71         return strIn + " " + super.toString();
72     }
73 }
74
Popular Tags