Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

ResultSetMetaData.java

00001 /**
00002  * C-JDBC: Clustered JDBC.
00003  * Copyright (C) 2002-2004 French National Institute For Research In Computer
00004  * Science And Control (INRIA).
00005  * Contact: c-jdbc@objectweb.org
00006  * 
00007  * This library is free software; you can redistribute it and/or modify it
00008  * under the terms of the GNU Lesser General Public License as published by the
00009  * Free Software Foundation; either version 2.1 of the License, or any later
00010  * version.
00011  * 
00012  * This library is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00015  * for more details.
00016  * 
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this library; if not, write to the Free Software Foundation,
00019  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00020  *
00021  * Initial developer(s): Emmanuel Cecchet.
00022  * Contributor(s): __________________.
00023  */
00024 
00025 package org.objectweb.cjdbc.driver;
00026 
00027 import java.sql.SQLException;
00028 
00029 /**
00030  * ResultSet metadata provided for pretty printing of the ResultSet by a
00031  * console.
00032  * 
00033  * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet</a>
00034  * @version 1.0
00035  */
00036 public class ResultSetMetaData implements java.sql.ResultSetMetaData
00037 {
00038   private DriverResultSet rs;
00039 
00040   /**
00041    * Constructs a ResultSetMetaData from a C-JDBC ResultSet.
00042    * 
00043    * @param rs the ResultSet
00044    */
00045   public ResultSetMetaData(DriverResultSet rs)
00046   {
00047     this.rs = rs;
00048   }
00049 
00050   /**
00051    * @see java.sql.ResultSetMetaData#getColumnCount()
00052    */
00053   public int getColumnCount() throws SQLException
00054   {
00055     return rs.nbOfColumns;
00056   }
00057 
00058   /**
00059    * @see java.sql.ResultSetMetaData#isAutoIncrement(int)
00060    */
00061   public boolean isAutoIncrement(int column) throws SQLException
00062   {
00063     if ((column < 1) || (column > rs.nbOfColumns))
00064       throw new SQLException("Invalid column index " + column);
00065     return rs.fields[column - 1].isAutoIncrement();
00066   }
00067 
00068   /**
00069    * @see java.sql.ResultSetMetaData#isCaseSensitive(int)
00070    */
00071   public boolean isCaseSensitive(int column) throws SQLException
00072   {
00073     if ((column < 1) || (column > rs.nbOfColumns))
00074       throw new SQLException("Invalid column index " + column);
00075     return rs.fields[column - 1].isCaseSensitive();
00076   }
00077 
00078   /**
00079    * @see java.sql.ResultSetMetaData#isSearchable(int)
00080    */
00081   public boolean isSearchable(int column) throws SQLException
00082   {
00083     if ((column < 1) || (column > rs.nbOfColumns))
00084       throw new SQLException("Invalid column index " + column);
00085     return rs.fields[column - 1].isSearchable();
00086   }
00087 
00088   /**
00089    * @see java.sql.ResultSetMetaData#isCurrency(int)
00090    */
00091   public boolean isCurrency(int column) throws SQLException
00092   {
00093     if ((column < 1) || (column > rs.nbOfColumns))
00094       throw new SQLException("Invalid column index " + column);
00095     return rs.fields[column - 1].isCurrency();
00096   }
00097 
00098   /**
00099    * @see java.sql.ResultSetMetaData#isNullable(int)
00100    */
00101   public int isNullable(int column) throws SQLException
00102   {
00103     if ((column < 1) || (column > rs.nbOfColumns))
00104       throw new SQLException("Invalid column index " + column);
00105     return rs.fields[column - 1].isNullable();
00106   }
00107 
00108   /**
00109    * @see java.sql.ResultSetMetaData#isSigned(int)
00110    */
00111   public boolean isSigned(int column) throws SQLException
00112   {
00113     if ((column < 1) || (column > rs.nbOfColumns))
00114       throw new SQLException("Invalid column index " + column);
00115     return rs.fields[column - 1].isSigned();
00116   }
00117 
00118   /**
00119    * @see java.sql.ResultSetMetaData#getColumnDisplaySize(int)
00120    */
00121   public int getColumnDisplaySize(int column) throws SQLException
00122   {
00123     if ((column < 1) || (column > rs.nbOfColumns))
00124       throw new SQLException("Invalid column index " + column);
00125     return rs.fields[column - 1].getColumnDisplaySize();
00126   }
00127 
00128   /**
00129    * @see java.sql.ResultSetMetaData#getColumnLabel(int)
00130    */
00131   public String getColumnLabel(int column) throws SQLException
00132   {
00133     if ((column < 1) || (column > rs.nbOfColumns))
00134       throw new SQLException("Invalid column index " + column);
00135     return rs.fields[column - 1].getFieldName();
00136   }
00137 
00138   /**
00139    * @see java.sql.ResultSetMetaData#getColumnName(int)
00140    */
00141   public String getColumnName(int column) throws SQLException
00142   {
00143     if ((column < 1) || (column > rs.nbOfColumns))
00144       throw new SQLException("Invalid column index " + column);
00145     return rs.fields[column - 1].getFieldName();
00146   }
00147 
00148   /**
00149    * @see java.sql.ResultSetMetaData#getSchemaName(int)
00150    */
00151   public String getSchemaName(int column) throws SQLException
00152   {
00153     if ((column < 1) || (column > rs.nbOfColumns))
00154       throw new SQLException("Invalid column index " + column);
00155     return rs.fields[column - 1].getFullName();
00156   }
00157 
00158   /**
00159    * @see java.sql.ResultSetMetaData#getPrecision(int)
00160    */
00161   public int getPrecision(int column) throws SQLException
00162   {
00163     if ((column < 1) || (column > rs.nbOfColumns))
00164       throw new SQLException("Invalid column index " + column);
00165     return rs.fields[column - 1].getPrecision();
00166   }
00167 
00168   /**
00169    * @see java.sql.ResultSetMetaData#getScale(int)
00170    */
00171   public int getScale(int column) throws SQLException
00172   {
00173     if ((column < 1) || (column > rs.nbOfColumns))
00174       throw new SQLException("Invalid column index " + column);
00175     return rs.fields[column - 1].getScale();
00176   }
00177 
00178   /**
00179    * @see java.sql.ResultSetMetaData#getTableName(int)
00180    */
00181   public String getTableName(int column) throws SQLException
00182   {
00183     if ((column < 1) || (column > rs.nbOfColumns))
00184       throw new SQLException("Invalid column index " + column);
00185     return rs.fields[column - 1].getTableName();
00186   }
00187 
00188   /**
00189    * @see java.sql.ResultSetMetaData#getCatalogName(int)
00190    */
00191   public String getCatalogName(int column) throws SQLException
00192   {
00193     if ((column < 1) || (column > rs.nbOfColumns))
00194       throw new SQLException("Invalid column index " + column);
00195     return "";
00196   }
00197 
00198   /**
00199    * @see java.sql.ResultSetMetaData#getColumnType(int)
00200    */
00201   public int getColumnType(int column) throws SQLException
00202   {
00203     if ((column < 1) || (column > rs.nbOfColumns))
00204       throw new SQLException("Invalid column index " + column);
00205     return rs.fields[column - 1].getSqlType();
00206   }
00207 
00208   /**
00209    * @see java.sql.ResultSetMetaData#getColumnTypeName(int)
00210    */
00211   public String getColumnTypeName(int column) throws SQLException
00212   {
00213     if ((column < 1) || (column > rs.nbOfColumns))
00214       throw new SQLException("Invalid column index " + column);
00215     return rs.fields[column - 1].getTypeName();
00216   }
00217 
00218   /**
00219    * @see java.sql.ResultSetMetaData#isReadOnly(int)
00220    */
00221   public boolean isReadOnly(int column) throws SQLException
00222   {
00223     if ((column < 1) || (column > rs.nbOfColumns))
00224       throw new SQLException("Invalid column index " + column);
00225     return rs.fields[column - 1].isReadOnly();
00226   }
00227 
00228   /**
00229    * @see java.sql.ResultSetMetaData#isWritable(int)
00230    */
00231   public boolean isWritable(int column) throws SQLException
00232   {
00233     if ((column < 1) || (column > rs.nbOfColumns))
00234       throw new SQLException("Invalid column index " + column);
00235     return rs.fields[column - 1].isWritable();
00236   }
00237 
00238   /**
00239    * @see java.sql.ResultSetMetaData#isDefinitelyWritable(int)
00240    */
00241   public boolean isDefinitelyWritable(int column) throws SQLException
00242   {
00243     if ((column < 1) || (column > rs.nbOfColumns))
00244       throw new SQLException("Invalid column index " + column);
00245     return rs.fields[column - 1].isDefinitelyWritable();
00246   }
00247 
00248   /**
00249    * @see java.sql.ResultSetMetaData#getColumnClassName(int)
00250    */
00251   public String getColumnClassName(int column) throws SQLException
00252   {
00253     if ((column < 1) || (column > rs.nbOfColumns))
00254       throw new SQLException("Invalid column index " + column);
00255     return rs.fields[column - 1].getColumnClassName();
00256   }
00257 
00258 }

Generated on Mon Apr 11 22:01:34 2005 for C-JDBC by  doxygen 1.3.9.1