jxUtil 0.6

org.sourceforge.jxutil.sql.type
Class AbstractType

java.lang.Object
  |
  +--org.sourceforge.jxutil.sql.type.AbstractType
Direct Known Subclasses:
AbstractARRAY, AbstractBIGINT, AbstractBOOLEAN, AbstractDATE, AbstractDOUBLE, AbstractINTEGER, AbstractLONGVARBINARY, AbstractNUMERIC, AbstractREAL, AbstractSMALLINT, AbstractText, AbstractTIME, AbstractTIMESTAMP, AbstractTINYINT, DefaultVOID, ProxyType

public abstract class AbstractType
extends Object

Baseclass for all Types supported by the driver. All operations on data retrieved from or sent to the database is handled by instances of classes extending AbstractType. The methods of this class have to perform all necessary conversions.
TODO:


Field Summary
protected static BigDecimal BD_ONE
           
protected static BigDecimal BD_ZERO
           
protected  String name
          The type's unique database specific typename.
 
Constructor Summary
protected AbstractType(String name)
          Construct a type with a given typename.
 
Method Summary
protected  DataTruncation dataTruncationRead(ConversionContext ctx, Object rval, Object val)
          Report a DataTruncation warning.
protected  DataTruncation dataTruncationWrite(ConversionContext ctx, Object wval, Object val)
          Report a DataTruncation exception.
 AbstractType deriveType(int d)
          Derive a type from this type, modifying it according to the given integer parameter.
 Array getArray(Object row, ConversionContext ctx)
           
 InputStream getAsciiStream(Object row, ConversionContext ctx)
           
 boolean getAutoInc()
          Get whether this type is automatically incrementing.
 BigDecimal getBigDecimal(Object row, ConversionContext ctx)
          Get a BigDecimal.
 InputStream getBinaryStream(Object row, ConversionContext ctx)
           
 Blob getBlob(Object row, ConversionContext ctx)
           
 boolean getBoolean(Object row, ConversionContext ctx)
          Get a boolean.
 byte getByte(Object row, ConversionContext ctx)
          Get a byte.
 byte[] getBytes(Object row, ConversionContext ctx)
           
 boolean getCaseSensitive()
          Get whether data of this type is treated case sensitive.
 Reader getCharacterStream(Object row, ConversionContext ctx)
           
 Clob getClob(Object row, ConversionContext ctx)
           
 String getCreateParams()
          Get the additional parameters to supply in a CREATE TABLE statement using this type.
 boolean getCurrency()
          Get whether this type is a currency type.
 Date getDate(Object row, Calendar cal, ConversionContext ctx)
          Get a Date using given Calendar.
 Date getDate(Object row, ConversionContext ctx)
          Get a Date.
 double getDouble(Object row, ConversionContext ctx)
          Get a double.
 float getFloat(Object row, ConversionContext ctx)
          Get a float.
 int getInt(Object row, ConversionContext ctx)
          Get an int.
 Class getJavaClass()
          Get the Java Class returned when calling getObject on this type.
 Class getJavaType()
          Get the Java Class of the primitive type best representing data of this database type.
abstract  int getJDBCType()
          Get the type's closest representation as a JDBC type.
 String getLiteral(Object row, ConversionContext ctx)
          Get a literal value.
 String getLiteralPrefix()
          Get the prefix to use for literal data of this type.
 String getLiteralSuffix()
          Get the suffix to use for literal data of this type.
 String getLocalName()
          Get the type's local name.
 long getLong(Object row, ConversionContext ctx)
          Get a long.
 short getMaxScale()
          Get the type's maximum allowed scale.
 short getMinScale()
          Get the type's minimum allowed scale.
 String getName()
          Get the type's name.
 int getNullable()
          Get whether this type can be nulled.
 int getNumRadix()
          Get the type's numeric radix.
 Object getObject(Object row, ConversionContext ctx)
           
 Object getObject(Object row, Map map, ConversionContext ctx)
           
 int getPrecision()
          Get the type's precision.
 Ref getRef(Object row, ConversionContext ctx)
           
 int getScale()
          Get the type's scale.
 int getSearchable()
          Get whether columns of this type can be used in search constructs.
 short getShort(Object row, ConversionContext ctx)
          Get a short.
 String getString(Object row, ConversionContext ctx)
           
 Time getTime(Object row, Calendar cal, ConversionContext ctx)
          Get a Time using given Calendar.
 Time getTime(Object row, ConversionContext ctx)
          Get a Time.
 Timestamp getTimestamp(Object row, Calendar cal, ConversionContext ctx)
           
 Timestamp getTimestamp(Object row, ConversionContext ctx)
           
 boolean getUnsigned()
          Get whether data of this type is unsigned.
 URL getURL(Object row, ConversionContext ctx)
           
protected  SQLException noConversion(String accessor)
           
protected  SQLException noConversion(String accessor, Class paramClass, Object paramObject)
           
protected  SQLException noConversion(String accessor, Object paramObject)
           
 void setArray(Object row, Array val, ConversionContext ctx)
           
 void setAsciiStream(Object row, InputStream in, int length, ConversionContext ctx)
           
 void setBigDecimal(Object row, BigDecimal val, ConversionContext ctx)
           
 void setBinaryStream(Object row, InputStream in, int length, ConversionContext ctx)
           
 void setBlob(Object row, Blob val, ConversionContext ctx)
           
 void setBoolean(Object row, boolean val, ConversionContext ctx)
           
 void setByte(Object row, byte val, ConversionContext ctx)
           
 void setBytes(Object row, byte[] val, ConversionContext ctx)
           
 void setCharacterStream(Object row, Reader in, int length, ConversionContext ctx)
           
 void setClob(Object row, Clob val, ConversionContext ctx)
           
 void setDate(Object row, Date val, Calendar cal, ConversionContext ctx)
           
 void setDate(Object row, Date val, ConversionContext ctx)
           
 void setDouble(Object row, double val, ConversionContext ctx)
           
 void setFloat(Object row, float val, ConversionContext ctx)
           
 void setInt(Object row, int val, ConversionContext ctx)
           
 void setLong(Object row, long val, ConversionContext ctx)
           
 void setNull(Object row, ConversionContext ctx)
           
 void setNull(Object row, int parameterType, ConversionContext ctx)
           
 void setNull(Object row, int parameterType, String parameterName, ConversionContext ctx)
           
 void setObject(Object row, Object val, ConversionContext ctx)
           
 void setObject(Object row, Object val, int target, ConversionContext ctx)
          Set value from Object.
 void setObject(Object row, Object val, int target, int scale, ConversionContext ctx)
          Set value from Object.
 void setRef(Object row, Ref val, ConversionContext ctx)
           
 void setShort(Object row, short val, ConversionContext ctx)
           
 void setString(Object row, String val, ConversionContext ctx)
           
 void setStruct(Object row, Struct val, ConversionContext ctx)
           
 void setTime(Object row, Time val, Calendar cal, ConversionContext ctx)
           
 void setTime(Object row, Time val, ConversionContext ctx)
           
 void setTimestamp(Object row, Timestamp val, Calendar cal, ConversionContext ctx)
           
 void setTimestamp(Object row, Timestamp val, ConversionContext ctx)
           
 void setURL(Object row, URL val, ConversionContext ctx)
           
 String toString()
          Print lots of information on this type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BD_ONE

protected static final BigDecimal BD_ONE

BD_ZERO

protected static final BigDecimal BD_ZERO

name

protected final String name
The type's unique database specific typename.

Constructor Detail

AbstractType

protected AbstractType(String name)
Construct a type with a given typename.

Method Detail

dataTruncationRead

protected final DataTruncation dataTruncationRead(ConversionContext ctx,
                                                  Object rval,
                                                  Object val)
Report a DataTruncation warning.

Parameters:
rval - The value read
val - The original value in the database

dataTruncationWrite

protected final DataTruncation dataTruncationWrite(ConversionContext ctx,
                                                   Object wval,
                                                   Object val)
Report a DataTruncation exception.

Parameters:
wval - The value written
val - The original value

deriveType

public AbstractType deriveType(int d)
Derive a type from this type, modifying it according to the given integer parameter. By default the type is returned as-is.


getArray

public Array getArray(Object row,
                      ConversionContext ctx)
               throws SQLException
SQLException

getAsciiStream

public InputStream getAsciiStream(Object row,
                                  ConversionContext ctx)
                           throws SQLException
SQLException

getAutoInc

public boolean getAutoInc()
Get whether this type is automatically incrementing.


getBigDecimal

public BigDecimal getBigDecimal(Object row,
                                ConversionContext ctx)
                         throws SQLException
Get a BigDecimal.

SQLException

getBinaryStream

public InputStream getBinaryStream(Object row,
                                   ConversionContext ctx)
                            throws SQLException
SQLException

getBlob

public Blob getBlob(Object row,
                    ConversionContext ctx)
             throws SQLException
SQLException

getBoolean

public boolean getBoolean(Object row,
                          ConversionContext ctx)
                   throws SQLException
Get a boolean.

SQLException

getByte

public byte getByte(Object row,
                    ConversionContext ctx)
             throws SQLException
Get a byte.

SQLException

getBytes

public byte[] getBytes(Object row,
                       ConversionContext ctx)
                throws SQLException
SQLException

getCaseSensitive

public boolean getCaseSensitive()
Get whether data of this type is treated case sensitive.


getCharacterStream

public Reader getCharacterStream(Object row,
                                 ConversionContext ctx)
                          throws SQLException
SQLException

getClob

public Clob getClob(Object row,
                    ConversionContext ctx)
             throws SQLException
SQLException

getCreateParams

public String getCreateParams()
Get the additional parameters to supply in a CREATE TABLE statement using this type.


getCurrency

public boolean getCurrency()
Get whether this type is a currency type.


getDate

public Date getDate(Object row,
                    Calendar cal,
                    ConversionContext ctx)
             throws SQLException
Get a Date using given Calendar.

SQLException

getDate

public final Date getDate(Object row,
                          ConversionContext ctx)
                   throws SQLException
Get a Date.

SQLException

getDouble

public double getDouble(Object row,
                        ConversionContext ctx)
                 throws SQLException
Get a double.

SQLException

getFloat

public float getFloat(Object row,
                      ConversionContext ctx)
               throws SQLException
Get a float.

SQLException

getInt

public int getInt(Object row,
                  ConversionContext ctx)
           throws SQLException
Get an int.

SQLException

getJavaClass

public Class getJavaClass()
Get the Java Class returned when calling getObject on this type.


getJavaType

public Class getJavaType()
Get the Java Class of the primitive type best representing data of this database type.


getJDBCType

public abstract int getJDBCType()
Get the type's closest representation as a JDBC type.

See Also:
Types

getLiteral

public String getLiteral(Object row,
                         ConversionContext ctx)
                  throws SQLException
Get a literal value.

SQLException

getLiteralPrefix

public String getLiteralPrefix()
Get the prefix to use for literal data of this type.


getLiteralSuffix

public String getLiteralSuffix()
Get the suffix to use for literal data of this type.


getLocalName

public String getLocalName()
Get the type's local name.


getLong

public long getLong(Object row,
                    ConversionContext ctx)
             throws SQLException
Get a long.

SQLException

getMaxScale

public short getMaxScale()
Get the type's maximum allowed scale.


getMinScale

public short getMinScale()
Get the type's minimum allowed scale.


getName

public final String getName()
Get the type's name.


getNullable

public int getNullable()
Get whether this type can be nulled.


getNumRadix

public int getNumRadix()
Get the type's numeric radix.


getObject

public final Object getObject(Object row,
                              ConversionContext ctx)
                       throws SQLException
SQLException

getObject

public Object getObject(Object row,
                        Map map,
                        ConversionContext ctx)
                 throws SQLException
SQLException

getPrecision

public int getPrecision()
Get the type's precision.


getRef

public Ref getRef(Object row,
                  ConversionContext ctx)
           throws SQLException
SQLException

getScale

public int getScale()
Get the type's scale.


getSearchable

public int getSearchable()
Get whether columns of this type can be used in search constructs.


getShort

public short getShort(Object row,
                      ConversionContext ctx)
               throws SQLException
Get a short.

SQLException

getString

public String getString(Object row,
                        ConversionContext ctx)
                 throws SQLException
SQLException

getTime

public Time getTime(Object row,
                    Calendar cal,
                    ConversionContext ctx)
             throws SQLException
Get a Time using given Calendar.

SQLException

getTime

public final Time getTime(Object row,
                          ConversionContext ctx)
                   throws SQLException
Get a Time.

SQLException

getTimestamp

public Timestamp getTimestamp(Object row,
                              Calendar cal,
                              ConversionContext ctx)
                       throws SQLException
SQLException

getTimestamp

public final Timestamp getTimestamp(Object row,
                                    ConversionContext ctx)
                             throws SQLException
SQLException

getUnsigned

public boolean getUnsigned()
Get whether data of this type is unsigned.


getURL

public URL getURL(Object row,
                  ConversionContext ctx)
           throws SQLException
SQLException

noConversion

protected final SQLException noConversion(String accessor)
                                   throws SQLException
SQLException

noConversion

protected final SQLException noConversion(String accessor,
                                          Class paramClass,
                                          Object paramObject)
                                   throws SQLException
SQLException

noConversion

protected final SQLException noConversion(String accessor,
                                          Object paramObject)
                                   throws SQLException
SQLException

setArray

public void setArray(Object row,
                     Array val,
                     ConversionContext ctx)
              throws SQLException
SQLException

setAsciiStream

public void setAsciiStream(Object row,
                           InputStream in,
                           int length,
                           ConversionContext ctx)
                    throws SQLException
SQLException

setBigDecimal

public void setBigDecimal(Object row,
                          BigDecimal val,
                          ConversionContext ctx)
                   throws SQLException
SQLException

setBinaryStream

public void setBinaryStream(Object row,
                            InputStream in,
                            int length,
                            ConversionContext ctx)
                     throws SQLException
SQLException

setBlob

public void setBlob(Object row,
                    Blob val,
                    ConversionContext ctx)
             throws SQLException
SQLException

setBoolean

public void setBoolean(Object row,
                       boolean val,
                       ConversionContext ctx)
                throws SQLException
SQLException

setByte

public void setByte(Object row,
                    byte val,
                    ConversionContext ctx)
             throws SQLException
SQLException

setBytes

public void setBytes(Object row,
                     byte[] val,
                     ConversionContext ctx)
              throws SQLException
SQLException

setCharacterStream

public void setCharacterStream(Object row,
                               Reader in,
                               int length,
                               ConversionContext ctx)
                        throws SQLException
SQLException

setClob

public void setClob(Object row,
                    Clob val,
                    ConversionContext ctx)
             throws SQLException
SQLException

setDate

public void setDate(Object row,
                    Date val,
                    Calendar cal,
                    ConversionContext ctx)
             throws SQLException
SQLException

setDate

public final void setDate(Object row,
                          Date val,
                          ConversionContext ctx)
                   throws SQLException
SQLException

setDouble

public void setDouble(Object row,
                      double val,
                      ConversionContext ctx)
               throws SQLException
SQLException

setFloat

public void setFloat(Object row,
                     float val,
                     ConversionContext ctx)
              throws SQLException
SQLException

setInt

public void setInt(Object row,
                   int val,
                   ConversionContext ctx)
            throws SQLException
SQLException

setLong

public void setLong(Object row,
                    long val,
                    ConversionContext ctx)
             throws SQLException
SQLException

setNull

public void setNull(Object row,
                    ConversionContext ctx)
             throws SQLException
SQLException

setNull

public void setNull(Object row,
                    int parameterType,
                    ConversionContext ctx)
             throws SQLException
SQLException

setNull

public void setNull(Object row,
                    int parameterType,
                    String parameterName,
                    ConversionContext ctx)
             throws SQLException
SQLException

setObject

public void setObject(Object row,
                      Object val,
                      ConversionContext ctx)
               throws SQLException
SQLException

setObject

public void setObject(Object row,
                      Object val,
                      int target,
                      ConversionContext ctx)
               throws SQLException
Set value from Object. The target parameter is ignored.

SQLException

setObject

public void setObject(Object row,
                      Object val,
                      int target,
                      int scale,
                      ConversionContext ctx)
               throws SQLException
Set value from Object. The target and scale parameters are ignored.

SQLException

setRef

public void setRef(Object row,
                   Ref val,
                   ConversionContext ctx)
            throws SQLException
SQLException

setShort

public void setShort(Object row,
                     short val,
                     ConversionContext ctx)
              throws SQLException
SQLException

setString

public void setString(Object row,
                      String val,
                      ConversionContext ctx)
               throws SQLException
SQLException

setStruct

public void setStruct(Object row,
                      Struct val,
                      ConversionContext ctx)
               throws SQLException
SQLException

setTime

public void setTime(Object row,
                    Time val,
                    Calendar cal,
                    ConversionContext ctx)
             throws SQLException
SQLException

setTime

public final void setTime(Object row,
                          Time val,
                          ConversionContext ctx)
                   throws SQLException
SQLException

setTimestamp

public void setTimestamp(Object row,
                         Timestamp val,
                         Calendar cal,
                         ConversionContext ctx)
                  throws SQLException
SQLException

setTimestamp

public final void setTimestamp(Object row,
                               Timestamp val,
                               ConversionContext ctx)
                        throws SQLException
SQLException

setURL

public void setURL(Object row,
                   URL val,
                   ConversionContext ctx)
            throws SQLException
SQLException

toString

public String toString()
Print lots of information on this type.

Overrides:
toString in class Object

jxUtil 0.6

Copyright © 2001,2002 Keve Müller, et al.; see LICENSE file for details.