001 package org.apache.ojb.broker.metadata;
002
003 /* Copyright 2003-2005 The Apache Software Foundation
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 import java.sql.ResultSet;
019 import java.sql.CallableStatement;
020 import java.sql.SQLException;
021 import java.io.Serializable;
022
023 import org.apache.ojb.broker.util.sequence.SequenceManagerException;
024
025 /**
026 * Represents a jdbc sql type object defined by the JDBC 3.0 specification to handle
027 * data conversion (see JDBC 3.0 specification <em>Appendix B, Data Type Conversion Tables</em>).
028 *
029 * @see FieldType
030 * @version $Id: JdbcType.java,v 1.1 2007-08-24 22:17:29 ewestfal Exp $
031 */
032 public interface JdbcType extends Serializable
033 {
034 /**
035 * Intern used flag.
036 */
037 public static final int MIN_INT = Integer.MIN_VALUE;
038
039 /**
040 * Returns an java object for this jdbc type by extract from the given
041 * CallableStatement or ResultSet.
042 * <br/>
043 * NOTE: For internal use only!!
044 * <br/>
045 * Exactly one of the arguments of type CallableStatement or ResultSet
046 * have to be non-null. If the 'columnId' argument is equals {@link #MIN_INT}, then the given 'columnName'
047 * argument is used to lookup column. Else the given 'columnId' is used as column index.
048 */
049 public Object getObjectFromColumn(ResultSet rs, CallableStatement stmt, String columnName, int columnId)
050 throws SQLException;
051
052 /**
053 * Convenience method for {@link #getObjectFromColumn(ResultSet, CallableStatement, String, int)}
054 */
055 public Object getObjectFromColumn(CallableStatement stmt, int columnId) throws SQLException;
056
057 /**
058 * Convenience method for {@link #getObjectFromColumn(ResultSet, CallableStatement, String, int)}
059 */
060 public Object getObjectFromColumn(ResultSet rs, String columnName) throws SQLException;
061
062 /**
063 * Convert the given {@link java.lang.Long} value to
064 * a java object representation of this jdbc type.
065 */
066 public Object sequenceKeyConversion(Long identifier) throws SequenceManagerException;
067
068 /**
069 * Returns the representing {@link java.sql.Types sql type}.
070 */
071 public int getType();
072
073 /**
074 * Indicates whether some other object is "equal to" this one.
075 */
076 public boolean equals(Object obj);
077
078 /**
079 * Returns the associated {@link FieldType} (java field type mapped to this sql type).
080 */
081 public FieldType getFieldType();
082
083 // // not used in code, but maybe useful in further versions
084 // /**
085 // * Convenience method for {@link #getObjectFromColumn(ResultSet, CallableStatement, String, int)}
086 // */
087 // Object getObjectFromColumn(CallableStatement stmt, String columnName) throws SQLException;
088 // /**
089 // * Convenience method for {@link #getObjectFromColumn(ResultSet, CallableStatement, String, int)}
090 // */
091 // Object getObjectFromColumn(ResultSet rs, int columnId) throws SQLException;
092 }