home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / JDBC / JDBC_TES / JDBCTEST / EXAMPLE / SUPPORTE.JAV < prev   
Encoding:
Text File  |  1996-10-18  |  6.7 KB  |  210 lines

  1. /*
  2.  * Copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved.
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software
  5.  * and its documentation for NON-COMMERCIAL purposes and without
  6.  * fee is hereby granted provided that this copyright notice
  7.  * appears in all copies. Please refer to the file "LICENSE"
  8.  * for further important copyright and licensing information.
  9.  *
  10.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  11.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  12.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  13.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  14.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  15.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  16.  *
  17.  * THIS SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE OR RESALE AS ON-LINE
  18.  * CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE
  19.  * PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT
  20.  * NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT LIFE
  21.  * SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE
  22.  * SOFTWARE COULD LEAD DIRECTLY TO DEATH, PERSONAL INJURY, OR SEVERE
  23.  * PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH RISK ACTIVITIES").  SUN
  24.  * SPECIFICALLY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR
  25.  * HIGH RISK ACTIVITIES.
  26.  */
  27. package jdbcTest.harness;
  28. import java.sql.*;
  29. import java.util.*;
  30. /**
  31.  * SupportedSQLType is an object that represents a SQL type that is supported by
  32.  * an executing JDBC driver. It is constructed from an instance of a row in the result set
  33.  * returned by the getTypeInfo method of the DatabaseMetaData class.
  34.  * Accessor methods are provided for each data element. The names of these access methods
  35.  * correspond to the column names defines for the result set returned by getTypeInfo. The TYPE_NAME column,
  36.  * for example, is returned by invoking the getTypeName() method.*/
  37. public class SupportedSQLType{
  38.     String name;
  39.     short javaType;
  40.     int precision;
  41.     String prefix;
  42.     String suffix;
  43.     String parms;
  44.     short nullable;
  45.     boolean casesensitive;
  46.     short searchable;
  47.     boolean signed;
  48.     boolean currency;
  49.     boolean autoincrement;
  50.     String typeName;
  51.     short minScale;
  52.     short maxScale;
  53.     int radix;
  54.     public SupportedSQLType(    String iname,
  55.                 short ijavaType,
  56.                 int iprecision,
  57.                 String iprefix,
  58.                 String isuffix,
  59.                 String iparms,
  60.                 short inullable,
  61.                 boolean icasesensitive,
  62.                 short isearchable,
  63.                 boolean isigned,
  64.                 boolean icurrency,
  65.                 boolean iautoincrement,
  66.                 String itypeName,
  67.                 short iminScale,
  68.                 short imaxScale, int iradix ){
  69.  
  70.     name      =  iname==null?"unknown":iname;
  71.     javaType  =  ijavaType;
  72.     precision =  iprecision;
  73.     prefix      =  iprefix==null?"":iprefix;
  74.     suffix      =  isuffix==null?"":isuffix;
  75.     parms      =  iparms==null?"":iparms;
  76.     nullable  =  inullable;
  77.     casesensitive = icasesensitive;
  78.     searchable =  isearchable;
  79.     signed      =  isigned;
  80.     currency  =  icurrency;
  81.     autoincrement =  iautoincrement;
  82.     typeName  =  itypeName==null?"":itypeName;
  83.     minScale  =  iminScale;
  84.     maxScale  =  imaxScale;
  85.     radix     =  iradix;
  86.     }
  87.     public Object clone() {
  88.         return new SupportedSQLType(
  89.                     new String(name),
  90.                     javaType,
  91.                     precision,
  92.                     new String(prefix),
  93.                     new String(suffix),
  94.                     new String(parms),
  95.                     nullable,
  96.                     casesensitive,
  97.                     searchable,
  98.                     signed,
  99.                     currency,
  100.                     autoincrement,
  101.                     typeName,
  102.                     minScale,
  103.                     maxScale,
  104.                     radix                                   );
  105.     }
  106.     /**
  107.      * returns the TYPE_NAME column of an instance of the result set
  108.      * created by DatabaseMetaData.getTypeInfo() */
  109.     public String getTypeName() {
  110.     return(name);
  111.     }
  112.     /**
  113.      * returns the DATA_TYPE column of an instance of the result set
  114.      * created by DatabaseMetaData.getTypeInfo() */
  115.     public int getDataType() {
  116.     return(javaType);
  117.     }
  118.     /**
  119.      * returns the PRECISION column of an instance of the result set
  120.      * created by DatabaseMetaData.getTypeInfo() */
  121.     public int getPrecision() {
  122.     return(precision);
  123.     }
  124.     /**
  125.      * returns the LITERAL_PREFIX column of an instance of the result set
  126.      * created by DatabaseMetaData.getTypeInfo() */
  127.     public String getLiteralPrefix() {
  128.         if(prefix == null)
  129.             return("");
  130.         else
  131.         return(prefix);
  132.     }
  133.     /**
  134.      * returns the LITERAL_SUFFIX column of an instance of the result set
  135.      * created by DatabaseMetaData.getTypeInfo() */
  136.     public String getLiteralSuffix() {
  137.         if(suffix == null)
  138.             return("");
  139.         else
  140.         return(suffix);
  141.     }
  142.     /**
  143.      * returns the CREATE_PARAMS column of an instance of the result set
  144.      * created by DatabaseMetaData.getTypeInfo() */
  145.     public String getCreateParams() {
  146.     return(parms);
  147.     }
  148.     /**
  149.      * returns the TYPE_NAME column of an instance of the result set
  150.      * created by DatabaseMetaData.getTypeInfo() */
  151.     public short NULLABLE() {
  152.     return(nullable);
  153.     }
  154.     /**
  155.      * returns the CASE_SENSITIVE column of an instance of the result set
  156.      * created by DatabaseMetaData.getTypeInfo() */
  157.     public boolean getCaseSensitive(){
  158.     return(casesensitive);
  159.     }
  160.     /**
  161.      * returns the SEARCHABLE column of an instance of the result set
  162.      * created by DatabaseMetaData.getTypeInfo() */
  163.     public short getSearchable() {
  164.     return(searchable);
  165.     }
  166.     /**
  167.      * returns the UNSIGNED_ATTRIBUTE column of an instance of the result set
  168.      * created by DatabaseMetaData.getTypeInfo() */
  169.     public boolean getUnsignedAttribute() {
  170.     return(signed);
  171.     }
  172.     /**
  173.      * returns the FIXED_PREC_SCALE column of an instance of the result set
  174.      * created by DatabaseMetaData.getTypeInfo() */
  175.     public boolean getFixedPrecScale() {
  176.     return(currency);
  177.     }
  178.     /**
  179.      * returns the AUTO_INCREMENT column of an instance of the result set
  180.      * created by DatabaseMetaData.getTypeInfo() */
  181.     public boolean getAutoIncrement() {
  182.     return(autoincrement);
  183.     }
  184.     /**
  185.      * returns the LOCAL_TYPE_NAME column of an instance of the result set
  186.      * created by DatabaseMetaData.getTypeInfo() */
  187.     public String getLocalTypeName() {
  188.         return(typeName);
  189.     }
  190.     /**
  191.      * returns the MINIMUM_SCALE column of an instance of the result set
  192.      * created by DatabaseMetaData.getTypeInfo() */
  193.     public short getMinimumScale() {
  194.     return(minScale);
  195.     }
  196.     /**
  197.      * returns the MAXIMUM_SCALE column of an instance of the result set
  198.      * created by DatabaseMetaData.getTypeInfo() */
  199.     public short getMaximumScale() {
  200.     return(maxScale);
  201.     }
  202.     /**
  203.      * returns the NUM_PREC_RADIX column of an instance of the result set
  204.      * created by DatabaseMetaData.getTypeInfo() */
  205.     public int getNumPrecRadix(){
  206.         return(radix);
  207.     }
  208.  
  209. }
  210.