KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > jdbc > JdbcConverter


1
2 /*
3  * Copyright (c) 1998 - 2005 Versant Corporation
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Versant Corporation - initial API and implementation
11  */

12 package com.versant.core.jdbc;
13
14 import com.versant.core.jdbc.metadata.JdbcColumn;
15
16 import javax.jdo.JDOFatalDataStoreException; //todo: only referenced in "throws"-clause, discuss, whether to remove this
17

18 import java.sql.PreparedStatement JavaDoc;
19 import java.sql.SQLException JavaDoc;
20 import java.sql.ResultSet JavaDoc;
21
22 /**
23  * JdbcConverters are used to convert a column from a JDBC ResultSet into a
24  * Java object and to set a parameter of a PreparedStatement from a Java
25  * object. There are also extra methods used to support columns that need
26  * special handling (e.g. Oracle LOBs).
27  */

28 public interface JdbcConverter {
29
30     /**
31      * Is this converter for an Oracle style LOB column? Oracle LOBs require
32      * a hard coded a value into the insert/update statement instead of using
33      * a replaceable parameter and then select the value (if not null) and
34      * modify it.
35      */

36     public boolean isOracleStyleLOB();
37
38     /**
39      * This is only called if isOracleStyleLOB returns true. Get the String
40      * to be embedded in an SQL insert/update statement when the value for
41      * this column is not null (e.g. "empty_clob()");
42      */

43     public String JavaDoc getOracleStyleLOBNotNullString();
44
45     /**
46      * Get the value of col from rs at position index.
47      * @exception SQLException on SQL errors
48      * @exception JDOFatalDataStoreException if the ResultSet value is invalid
49      */

50     public Object JavaDoc get(ResultSet JavaDoc rs, int index, JdbcColumn col)
51             throws SQLException JavaDoc, JDOFatalDataStoreException;
52
53
54
55
56     /**
57      * Set parameter index on ps to value (for col). This is not called for
58      * converters that return true for isOracleStyleLOB.
59      * @exception SQLException on SQL errors
60      * @exception JDOFatalDataStoreException if value is invalid
61      * @see #isOracleStyleLOB
62      */

63     public void set(PreparedStatement JavaDoc ps, int index, JdbcColumn col, Object JavaDoc value)
64             throws SQLException JavaDoc, JDOFatalDataStoreException;
65
66     /**
67      * Set parameter index on ps to value (for col). This special form is used
68      * when the value to be set is available as an int to avoid creating
69      * an wrapper instance.
70      * @exception SQLException on SQL errors
71      * @exception JDOFatalDataStoreException if value is invalid
72      */

73     public void set(PreparedStatement JavaDoc ps, int index, JdbcColumn col, int value)
74             throws SQLException JavaDoc, JDOFatalDataStoreException;
75
76     /**
77      * This method is only called for converters that return true for
78      * isOracleStyleLOB. The LOB to be updated is at index in rs.
79      * @exception SQLException on SQL errors
80      * @exception JDOFatalDataStoreException if value is invalid
81      * @see #isOracleStyleLOB
82      */

83     public void set(ResultSet JavaDoc rs, int index, JdbcColumn col, Object JavaDoc value)
84             throws SQLException JavaDoc, JDOFatalDataStoreException;
85
86     /**
87      * Get the type of our expected value objects (e.g. java.util.Locale
88      * for a converter for Locale's). If the converter works with a primitive
89      * type e.g. Integer.TYPE then the corresponding wrapper class should be
90      * returned i.e. Integer.class.
91      */

92     public Class JavaDoc getValueType();
93 }
94
Popular Tags