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

Field.java

00001 /**
00002  * C-JDBC: Clustered JDBC.
00003  * Copyright (C) 2002-2005 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.io.Serializable;
00028 
00029 /**
00030  * Field is a class used to describe fields in a <code>ResultSet</code>.
00031  * <p>
00032  * The first version was inspired from the MM MySQL driver by Mark Matthews.
00033  * 
00034  * @see org.objectweb.cjdbc.driver.DriverResultSet
00035  * @see org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet
00036  * 
00037  * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
00038  * @author <a href="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
00039  * @version 1.0
00040  */
00041 public class Field implements Serializable
00042 {
00043   private int     scale;
00044   private int     precision;
00045   private boolean isSigned;
00046   private boolean isSearchable;
00047   private boolean isDefinitelyWritable;
00048   private boolean isWritable;
00049   private boolean isReadOnly;
00050   private int     isNullable;
00051   private boolean isCurrency;
00052   private boolean isCaseSensitive;
00053   private boolean isAutoIncrement;
00054   private String  tableName;
00055   private String  fieldName;
00056   private int     columnDisplaySize;
00057   private int     sqlType;
00058   private String  typeName;
00059   private String  columnClassName;
00060 
00061   /**
00062    * Create a new field with some default common values.
00063    * 
00064    * @param table the table name
00065    * @param name the field name
00066    * @param columnDisplaySize the column display size
00067    * @param sqlType the SQL type
00068    * @param typeName the type name
00069    * @param columnClassName the column class name
00070    */
00071   public Field(String table, String name, int columnDisplaySize, int sqlType,
00072       String typeName, String columnClassName)
00073   {
00074     this(table, name, columnDisplaySize, sqlType, typeName, columnClassName,
00075         false, true, false, ResultSetMetaData.columnNullable, true, false,
00076         false, false, false, 0, 0);
00077   }
00078 
00079   /**
00080    * Creates a new <code>Field</code> instance.
00081    * 
00082    * @param table the table name
00083    * @param name the field name
00084    * @param columnDisplaySize the column display size
00085    * @param sqlType the SQL type
00086    * @param typeName the type name
00087    * @param columnClassName the column class name
00088    * @param isAutoIncrement true if field is auto incremented
00089    * @param isCaseSensitive true if field is case sensitive
00090    * @param isCurrency true if field is currency
00091    * @param isNullable indicates the nullability of the field
00092    * @param isReadOnly true if field is read only
00093    * @param isWritable true if field is writable
00094    * @param isDefinitelyWritable true if field is definetly writable
00095    * @param isSearchable true if field is searchable
00096    * @param isSigned true if field is signed
00097    * @param precision decimal precision
00098    * @param scale number of digits to right of decimal point
00099    */
00100   public Field(String table, String name, int columnDisplaySize, int sqlType,
00101       String typeName, String columnClassName, boolean isAutoIncrement,
00102       boolean isCaseSensitive, boolean isCurrency, int isNullable,
00103       boolean isReadOnly, boolean isWritable, boolean isDefinitelyWritable,
00104       boolean isSearchable, boolean isSigned, int precision, int scale)
00105   {
00106     if (table == null)
00107       tableName = null;
00108     else
00109       tableName = new String(table);
00110     fieldName = new String(name);
00111     this.columnDisplaySize = columnDisplaySize;
00112     this.sqlType = sqlType;
00113     this.typeName = typeName;
00114     this.columnClassName = columnClassName;
00115     this.isAutoIncrement = isAutoIncrement;
00116     this.isCaseSensitive = isCaseSensitive;
00117     this.isCurrency = isCurrency;
00118     this.isNullable = isNullable;
00119     this.isReadOnly = isReadOnly;
00120     this.isWritable = isWritable;
00121     this.isDefinitelyWritable = isDefinitelyWritable;
00122     this.isSearchable = isSearchable;
00123     this.isSigned = isSigned;
00124     this.precision = precision;
00125     this.scale = scale;
00126   }
00127 
00128   /**
00129    * Gets the table name.
00130    * 
00131    * @return a <code>String</code> value
00132    */
00133   public String getTableName()
00134   {
00135     return tableName;
00136   }
00137 
00138   /**
00139    * Gets the field name.
00140    * 
00141    * @return a <code>String</code> value
00142    * @see #setFieldName
00143    */
00144   public String getFieldName()
00145   {
00146     return fieldName;
00147   }
00148 
00149   /**
00150    * Gets the full name: "tableName.fieldName"
00151    * 
00152    * @return a <code>String</code> value
00153    */
00154   public String getFullName()
00155   {
00156     return tableName + "." + fieldName;
00157   }
00158 
00159   /**
00160    * Sets the field name.
00161    * 
00162    * @param name the new field name
00163    * @see #getFieldName
00164    */
00165   public void setFieldName(String name)
00166   {
00167     fieldName = name;
00168   }
00169 
00170   /**
00171    * Returns the full name.
00172    * 
00173    * @return <code>String</code> value
00174    * @see #getFullName()
00175    */
00176   public String toString()
00177   {
00178     return getFullName();
00179   }
00180 
00181   /**
00182    * Returns the SQL type.
00183    * 
00184    * @return int Type according to java.sql.Types
00185    * @see java.sql.Types
00186    */
00187   public int getSqlType()
00188   {
00189     return sqlType;
00190   }
00191 
00192   /**
00193    * Returns the SQL type name.
00194    * 
00195    * @return the SQL type name
00196    */
00197   public String getTypeName()
00198   {
00199     return typeName;
00200   }
00201 
00202   /**
00203    * @see java.sql.ResultSetMetaData#getColumnClassName(int)
00204    */
00205   public String getColumnClassName()
00206   {
00207     return columnClassName;
00208   }
00209 
00210   /**
00211    * @see java.sql.ResultSetMetaData#getColumnDisplaySize(int)
00212    */
00213   public int getColumnDisplaySize()
00214   {
00215     return columnDisplaySize;
00216   }
00217 
00218   /**
00219    * @see java.sql.ResultSetMetaData#isAutoIncrement(int)
00220    */
00221   public boolean isAutoIncrement()
00222   {
00223     return isAutoIncrement;
00224   }
00225 
00226   /**
00227    * @see java.sql.ResultSetMetaData#isCaseSensitive(int)
00228    */
00229   public boolean isCaseSensitive()
00230   {
00231     return isCaseSensitive;
00232   }
00233 
00234   /**
00235    * @see java.sql.ResultSetMetaData#isCurrency(int)
00236    */
00237   public boolean isCurrency()
00238   {
00239     return isCurrency;
00240   }
00241 
00242   /**
00243    * @see java.sql.ResultSetMetaData#isDefinitelyWritable(int)
00244    */
00245   public boolean isDefinitelyWritable()
00246   {
00247     return isDefinitelyWritable;
00248   }
00249 
00250   /**
00251    * @see java.sql.ResultSetMetaData#isNullable(int)
00252    */
00253   public int isNullable()
00254   {
00255     return isNullable;
00256   }
00257 
00258   /**
00259    * @see java.sql.ResultSetMetaData#isReadOnly(int)
00260    */
00261   public boolean isReadOnly()
00262   {
00263     return isReadOnly;
00264   }
00265 
00266   /**
00267    * @see java.sql.ResultSetMetaData#isWritable(int)
00268    */
00269   public boolean isWritable()
00270   {
00271     return isWritable;
00272   }
00273 
00274   /**
00275    * @see java.sql.ResultSetMetaData#isSearchable(int)
00276    */
00277   public boolean isSearchable()
00278   {
00279     return isSearchable;
00280   }
00281 
00282   /**
00283    * @see java.sql.ResultSetMetaData#isSigned(int)
00284    */
00285   public boolean isSigned()
00286   {
00287     return isSigned;
00288   }
00289 
00290   /**
00291    * @see java.sql.ResultSetMetaData#getPrecision(int)
00292    */
00293   public int getPrecision()
00294   {
00295     return precision;
00296   }
00297 
00298   /**
00299    * @see java.sql.ResultSetMetaData#getScale(int)
00300    */
00301   public int getScale()
00302   {
00303     return scale;
00304   }
00305 
00306 }

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