net.sourceforge.jtds.jdbc

Class TypeInfo

Implemented Interfaces:
Comparable

public class TypeInfo
extends java.lang.Object
implements 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.5 2005/07/27 11:02:34 alin_sinpalean Exp $
Author:
David Eaves

Field Summary

(package private) static int
NUM_COLS
private boolean
autoIncrement
private boolean
caseSensitive
private String
createParams
private int
dataType
private int
distanceFromJdbcType
private boolean
fixedPrecScale
private String
literalPrefix
private String
literalSuffix
private String
localTypeName
private short
maximumScale
private short
minimumScale
private int
normalizedType
private short
nullable
private int
numPrecRadix
private int
precision
private short
searchable
private int
sqlDataType
private int
sqlDatetimeSub
private String
typeName
private boolean
unsigned

Constructor Summary

TypeInfo(ResultSet rs, boolean useLOBs)
TypeInfo(String typeName, int dataType, boolean autoIncrement)
For testing only.

Method Summary

private int
compare(int i1, int i2)
int
compareTo(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(Object o)
int
hashCode()
static int
normalizeDataType(int serverDataType, boolean useLOBs)
Return a java.sql.Types-defined type for an SQL Server specific data type.
String
toString()
void
update(ResultSet rs)

Field Details

NUM_COLS

(package private) static final int NUM_COLS
Field Value:
18

autoIncrement

private final boolean autoIncrement

caseSensitive

private final boolean caseSensitive

createParams

private final String createParams

dataType

private final int dataType

distanceFromJdbcType

private final int distanceFromJdbcType

fixedPrecScale

private final boolean fixedPrecScale

literalPrefix

private final String literalPrefix

literalSuffix

private final String literalSuffix

localTypeName

private final String localTypeName

maximumScale

private final short maximumScale

minimumScale

private final short minimumScale

normalizedType

private final int normalizedType

nullable

private final short nullable

numPrecRadix

private final int numPrecRadix

precision

private final int precision

searchable

private final short searchable

sqlDataType

private final int sqlDataType

sqlDatetimeSub

private final int sqlDatetimeSub

typeName

private final String typeName

unsigned

private final boolean unsigned

Constructor Details

TypeInfo

public TypeInfo(ResultSet rs,
                boolean useLOBs)
            throws SQLException

TypeInfo

public TypeInfo(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 Details

compare

private int compare(int i1,
                    int i2)

compareTo

public int compareTo(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.


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

equals

public boolean equals(Object o)

hashCode

public int hashCode()

normalizeDataType

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

toString

public String toString()

update

public void update(ResultSet rs)
            throws SQLException

Generated on September 18 2009