net.sourceforge.jtds.jdbc
Class TypeInfo

java.lang.Object
  |
  +--net.sourceforge.jtds.jdbc.TypeInfo
All Implemented Interfaces:
java.lang.Comparable

public class TypeInfo
extends java.lang.Object
implements java.lang.Comparable

Represents an SQL data type as required by getTypeInfo(). Provides a suitable natural ordering.

This class probably shouldn't be public, but is required to be so by the tests.

Version:
$Id: TypeInfo.java,v 1.1 2005/01/05 12:24:12 alin_sinpalean Exp $
Author:
David Eaves

Field Summary
private  boolean autoIncrement
           
private  boolean caseSensitive
           
private  java.lang.String createParams
           
private  int dataType
           
private  int distanceFromJdbcType
           
private  boolean fixedPrecScale
           
private  java.lang.String literalPrefix
           
private  java.lang.String literalSuffix
           
private  java.lang.String localTypeName
           
private  short maximumScale
           
private  short minimumScale
           
private  int normalizedType
           
private  short nullable
           
(package private) static int NUM_COLS
           
private  int numPrecRadix
           
private  int precision
           
private  short searchable
           
private  int sqlDataType
           
private  int sqlDatetimeSub
           
private  java.lang.String typeName
           
private  boolean unsigned
           
 
Constructor Summary
TypeInfo(java.sql.ResultSet rs)
           
TypeInfo(java.lang.String typeName, int dataType, boolean autoIncrement)
          For testing only.
 
Method Summary
private  int compare(int i1, int i2)
           
 int compareTo(java.lang.Object o)
          Comparable implementation that orders by dataType, then by how closely the data type maps to the corresponding JDBC SQL type.
private  int determineDistanceFromJdbcType()
          Determine how close this type is to the corresponding JDBC type.
 boolean equals(java.lang.Object o)
           
 int hashCode()
           
static int normalizeDataType(int serverDataType)
          Return a Types-defined type for an SQL Server specific data type.
 java.lang.String toString()
           
 void update(java.sql.ResultSet rs)
           
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

NUM_COLS

static final int NUM_COLS

typeName

private java.lang.String typeName

dataType

private int dataType

precision

private int precision

literalPrefix

private java.lang.String literalPrefix

literalSuffix

private java.lang.String literalSuffix

createParams

private java.lang.String createParams

nullable

private short nullable

caseSensitive

private boolean caseSensitive

searchable

private short searchable

unsigned

private boolean unsigned

fixedPrecScale

private boolean fixedPrecScale

autoIncrement

private boolean autoIncrement

localTypeName

private java.lang.String localTypeName

minimumScale

private short minimumScale

maximumScale

private short maximumScale

sqlDataType

private int sqlDataType

sqlDatetimeSub

private int sqlDatetimeSub

numPrecRadix

private int numPrecRadix

normalizedType

private int normalizedType

distanceFromJdbcType

private int distanceFromJdbcType
Constructor Detail

TypeInfo

public TypeInfo(java.sql.ResultSet rs)
         throws java.sql.SQLException

TypeInfo

public TypeInfo(java.lang.String typeName,
                int dataType,
                boolean autoIncrement)
For testing only. Create an instance with just the properties utilised in the compareTo() method (set name, type, and auto increment).
Method Detail

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

update

public void update(java.sql.ResultSet rs)
            throws java.sql.SQLException

compareTo

public int compareTo(java.lang.Object o)
Comparable implementation that orders by dataType, then by how closely the data type maps to the corresponding JDBC SQL type.

The data type values for the non-standard SQL Server types tend to have negative numbers while the corresponding standard types have positive numbers so utilise that in the sorting.

Specified by:
compareTo in interface java.lang.Comparable

compare

private int compare(int i1,
                    int i2)

determineDistanceFromJdbcType

private int determineDistanceFromJdbcType()
Determine how close this type is to the corresponding JDBC type. Used in sorting to distinguish between types that have the same normalizedType value.
Returns:
positive integer indicating how far away the type is from the corresponding JDBC type, with zero being the nearest possible match and 9 being the least

normalizeDataType

public static int normalizeDataType(int serverDataType)
Return a Types-defined type for an SQL Server specific data type.
Parameters:
serverDataType - the data type, as returned by the server
Returns:
the equivalent data type defined by java.sql.Types


Generated on April 15 2005