001/*
002 * Copyright 2002-2014 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.jdbc.support.rowset;
018
019import org.springframework.jdbc.InvalidResultSetAccessException;
020
021/**
022 * Metadata interface for Spring's {@link SqlRowSet}, analogous to JDBC's
023 * {@link java.sql.ResultSetMetaData}.
024 *
025 * <p>The main difference to the standard JDBC ResultSetMetaData is that a
026 * {@link java.sql.SQLException} is never thrown here. This allows
027 * SqlRowSetMetaData to be used without having to deal with checked exceptions.
028 * SqlRowSetMetaData will throw Spring's {@link InvalidResultSetAccessException}
029 * instead (when appropriate).
030 *
031 * @author Thomas Risberg
032 * @author Juergen Hoeller
033 * @since 1.2
034 * @see SqlRowSet#getMetaData()
035 * @see java.sql.ResultSetMetaData
036 * @see org.springframework.jdbc.InvalidResultSetAccessException
037 */
038public interface SqlRowSetMetaData {
039
040        /**
041         * Retrieve the catalog name of the table that served as the source for the
042         * specified column.
043         * @param columnIndex the index of the column
044         * @return the catalog name
045         * @see java.sql.ResultSetMetaData#getCatalogName(int)
046         */
047        String getCatalogName(int columnIndex) throws InvalidResultSetAccessException;
048
049        /**
050         * Retrieve the fully qualified class that the specified column will be mapped to.
051         * @param columnIndex the index of the column
052         * @return the class name as a String
053         * @see java.sql.ResultSetMetaData#getColumnClassName(int)
054         */
055        String getColumnClassName(int columnIndex) throws InvalidResultSetAccessException;
056
057        /**
058         * Retrieve the number of columns in the RowSet.
059         * @return the number of columns
060         * @see java.sql.ResultSetMetaData#getColumnCount()
061         */
062        int getColumnCount() throws InvalidResultSetAccessException;
063
064        /**
065         * Return the column names of the table that the result set represents.
066         * @return the column names
067         */
068        String[] getColumnNames() throws InvalidResultSetAccessException;
069
070        /**
071         * Retrieve the maximum width of the designated column.
072         * @param columnIndex the index of the column
073         * @return the width of the column
074         * @see java.sql.ResultSetMetaData#getColumnDisplaySize(int)
075         */
076        int getColumnDisplaySize(int columnIndex) throws InvalidResultSetAccessException;
077
078        /**
079         * Retrieve the suggested column title for the column specified.
080         * @param columnIndex the index of the column
081         * @return the column title
082         * @see java.sql.ResultSetMetaData#getColumnLabel(int)
083         */
084        String getColumnLabel(int columnIndex) throws InvalidResultSetAccessException;
085
086        /**
087         * Retrieve the column name for the indicated column.
088         * @param columnIndex the index of the column
089         * @return the column name
090         * @see java.sql.ResultSetMetaData#getColumnName(int)
091         */
092        String getColumnName(int columnIndex) throws InvalidResultSetAccessException;
093
094        /**
095         * Retrieve the SQL type code for the indicated column.
096         * @param columnIndex the index of the column
097         * @return the SQL type code
098         * @see java.sql.ResultSetMetaData#getColumnType(int)
099         * @see java.sql.Types
100         */
101        int getColumnType(int columnIndex) throws InvalidResultSetAccessException;
102
103        /**
104         * Retrieve the DBMS-specific type name for the indicated column.
105         * @param columnIndex the index of the column
106         * @return the type name
107         * @see java.sql.ResultSetMetaData#getColumnTypeName(int)
108         */
109        String getColumnTypeName(int columnIndex) throws InvalidResultSetAccessException;
110
111        /**
112         * Retrieve the precision for the indicated column.
113         * @param columnIndex the index of the column
114         * @return the precision
115         * @see java.sql.ResultSetMetaData#getPrecision(int)
116         */
117        int getPrecision(int columnIndex) throws InvalidResultSetAccessException;
118
119        /**
120         * Retrieve the scale of the indicated column.
121         * @param columnIndex the index of the column
122         * @return the scale
123         * @see java.sql.ResultSetMetaData#getScale(int)
124         */
125        int getScale(int columnIndex) throws InvalidResultSetAccessException;
126
127        /**
128         * Retrieve the schema name of the table that served as the source for the
129         * specified column.
130         * @param columnIndex the index of the column
131         * @return the schema name
132         * @see java.sql.ResultSetMetaData#getSchemaName(int)
133         */
134        String getSchemaName(int columnIndex) throws InvalidResultSetAccessException;
135
136        /**
137         * Retrieve the name of the table that served as the source for the
138         * specified column.
139         * @param columnIndex the index of the column
140         * @return the name of the table
141         * @see java.sql.ResultSetMetaData#getTableName(int)
142         */
143        String getTableName(int columnIndex) throws InvalidResultSetAccessException;
144
145        /**
146         * Indicate whether the case of the designated column is significant.
147         * @param columnIndex the index of the column
148         * @return true if the case sensitive, false otherwise
149         * @see java.sql.ResultSetMetaData#isCaseSensitive(int)
150         */
151        boolean isCaseSensitive(int columnIndex) throws InvalidResultSetAccessException;
152
153        /**
154         * Indicate whether the designated column contains a currency value.
155         * @param columnIndex the index of the column
156         * @return true if the value is a currency value, false otherwise
157         * @see java.sql.ResultSetMetaData#isCurrency(int)
158         */
159        boolean isCurrency(int columnIndex) throws InvalidResultSetAccessException;
160
161        /**
162         * Indicate whether the designated column contains a signed number.
163         * @param columnIndex the index of the column
164         * @return true if the column contains a signed number, false otherwise
165         * @see java.sql.ResultSetMetaData#isSigned(int)
166         */
167        boolean isSigned(int columnIndex) throws InvalidResultSetAccessException;
168
169}