org.axiondb.types
Class BaseDataType

java.lang.Object
  extended by org.axiondb.types.BaseDataType
All Implemented Interfaces:
Serializable, Comparator, DataType, DataTypeFactory
Direct Known Subclasses:
AnyType, BaseNumberDataType, BooleanType, CharacterType, LOBType, ObjectType, StringType, TimestampType, VarBinaryType

public abstract class BaseDataType
extends Object
implements DataType, DataTypeFactory

Abstract base implemention of DataType.

Version:
$Revision: 1.20 $ $Date: 2005/10/13 02:25:32 $
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.axiondb.DataType
DataType.BinaryRepresentation, DataType.ExactNumeric, DataType.NonFixedPrecision
 
Constructor Summary
BaseDataType()
           
 
Method Summary
abstract  boolean accepts(Object value)
          Return true if a field of my type can be assigned the given non- null value , false otherwise.
 int compare(Object a, Object b)
           
abstract  Object convert(Object value)
          Converts an acceptablevalue to one of the appropriate type.
 int getColumnDisplaySize()
          Value returned by ResultSetMetaData#getColumnDisplaySizefor this data type.
protected  Comparator getComparator()
          This base implementation simply returns a ComparableComparator.
abstract  int getJdbcType()
          Returns the JDBC type codemost closely matching this type.
 String getLiteralPrefix()
          Prefix used to quote a literal to delimit value for this type when in SQL syntax or result display
 String getLiteralSuffix()
          Suffix used to quote a literal to delimit value for this type when in SQL syntax or result display
 int getNullableCode()
          Code indicating that type does not accept, does accept, or does not disclose acceptance of null values
 int getPrecision()
          Value returned by ResultSetMetaData#getPrecisionfor this data type.
 int getPrecisionRadix()
          Indicates radix used to compute maximum number of significant digits for this datatype, as returned by DataType.getPrecision().
 String getPreferredValueClassName()
          Returns the "normal" type returned by DataType.convert(java.lang.Object).
 int getScale()
          Value returned by ResultSetMetaData#getScalefor this data type.
 short getSearchableCode()
          Code indicating how much WHERE ...
 boolean isCaseSensitive()
          For character and string-related types, indicates whether type acknowledges case when storing and retrieving values
 boolean isCurrency()
           
 boolean isUnsigned()
          For numeric types, indicates whether type stores only non-negative (>= 0) values
abstract  DataType makeNewInstance()
          Creates a new instance of this DataType implementation.
abstract  Object read(DataInput in)
          Instantiate an object of my type from the given DataInput.
 Object successor(Object value)
          Returns the successor for the given value.
 boolean supportsSuccessor()
          Returns true if the DataType.successor(java.lang.Object)method is supported, false otherwise.
 BigDecimal toBigDecimal(Object value)
          Convert the given non- null value to a BigDecimal, or throw a AxionException.
 BigInteger toBigInteger(Object value)
          Convert the given non- null value to a BigInteger, or throw a AxionException.
 Blob toBlob(Object value)
          Convert the given non- null value to a Blob, or throw a AxionException.
 boolean toBoolean(Object value)
          Convert the given non- null value to a boolean, or throw a SQLException.
 byte toByte(Object value)
          Convert the given non- null value to a byte, or throw a SQLException.
 byte[] toByteArray(Object value)
          Convert the given non- null value to a byte[], or throw a AxionException.
 Clob toClob(Object value)
          Convert the given non- null value to a Clob, or throw a AxionException.
 Date toDate(Object value)
          Convert the given non- null value to a Date, or throw a SQLException.
 double toDouble(Object value)
          Convert the given non- null value to a double, or throw a AxionException.
 float toFloat(Object value)
          Convert the given non- null value to a float, or throw a AxionException.
 int toInt(Object value)
          Convert the given non- null value to a int, or throw a AxionException.
 long toLong(Object value)
          Convert the given non- null value to a long, or throw a AxionException.
protected  Number toNumber(Object value)
           
 short toShort(Object value)
          Convert the given non- null value to a short, or throw a AxionException.
 String toString(Object value)
          Convert the given non- null value to a String, or throw a AxionException.
 Time toTime(Object value)
          Convert the given non- null value to a Time, or throw a AxionException.
 Timestamp toTimestamp(Object value)
          Convert the given non- null value to a Timestamp, or throw a AxionException.
 URL toURL(Object value)
          Convert the given non- null value to a URL, or throw a AxionException.
abstract  void write(Object value, DataOutput out)
          Write an object of my type to the given DataOutput.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

BaseDataType

public BaseDataType()
Method Detail

makeNewInstance

public abstract DataType makeNewInstance()
Description copied from interface: DataType
Creates a new instance of this DataType implementation.

Specified by:
makeNewInstance in interface DataType
Specified by:
makeNewInstance in interface DataTypeFactory
Returns:
new instance of this DataType implementation.

accepts

public abstract boolean accepts(Object value)
Description copied from interface: DataType
Return true if a field of my type can be assigned the given non- null value , false otherwise.

Specified by:
accepts in interface DataType
Parameters:
value - non- null value

convert

public abstract Object convert(Object value)
                        throws AxionException
Description copied from interface: DataType
Converts an acceptablevalue to one of the appropriate type.

Specified by:
convert in interface DataType
Throws:
AxionException

read

public abstract Object read(DataInput in)
                     throws IOException
Description copied from interface: DataType
Instantiate an object of my type from the given DataInput. The next sequence of bytes to be read from the DataInput will have been written by DataType.write(java.lang.Object, java.io.DataOutput).

Specified by:
read in interface DataType
Throws:
IOException

write

public abstract void write(Object value,
                           DataOutput out)
                    throws IOException
Description copied from interface: DataType
Write an object of my type to the given DataOutput.

Specified by:
write in interface DataType
Parameters:
value - the value to write, which must be acceptableto this DataType
Throws:
IOException

getJdbcType

public abstract int getJdbcType()
Description copied from interface: DataType
Returns the JDBC type codemost closely matching this type.

Specified by:
getJdbcType in interface DataType

getPreferredValueClassName

public String getPreferredValueClassName()
Description copied from interface: DataType
Returns the "normal" type returned by DataType.convert(java.lang.Object). Returns java.lang.Object if unknown.

Specified by:
getPreferredValueClassName in interface DataType
See Also:
AxionResultSetMetaData.getColumnClassName(int)

compare

public int compare(Object a,
                   Object b)
Specified by:
compare in interface Comparator

getComparator

protected Comparator getComparator()
This base implementation simply returns a ComparableComparator.


getColumnDisplaySize

public int getColumnDisplaySize()
Description copied from interface: DataType
Value returned by ResultSetMetaData#getColumnDisplaySizefor this data type.

Specified by:
getColumnDisplaySize in interface DataType
See Also:
ResultSetMetaData.getColumnDisplaySize(int)

getPrecision

public int getPrecision()
Description copied from interface: DataType
Value returned by ResultSetMetaData#getPrecisionfor this data type.

Specified by:
getPrecision in interface DataType
See Also:
ResultSetMetaData.getPrecision(int)

getScale

public int getScale()
Description copied from interface: DataType
Value returned by ResultSetMetaData#getScalefor this data type.

Specified by:
getScale in interface DataType
See Also:
ResultSetMetaData.getScale(int)

isCaseSensitive

public boolean isCaseSensitive()
Description copied from interface: DataType
For character and string-related types, indicates whether type acknowledges case when storing and retrieving values

Specified by:
isCaseSensitive in interface DataType
See Also:
DatabaseMetaData.getTypeInfo(), ResultSetMetaData.isCaseSensitive(int)

isCurrency

public boolean isCurrency()
Specified by:
isCurrency in interface DataType
See Also:
ResultSetMetaData.isCurrency(int)

getLiteralPrefix

public String getLiteralPrefix()
Description copied from interface: DataType
Prefix used to quote a literal to delimit value for this type when in SQL syntax or result display

Specified by:
getLiteralPrefix in interface DataType
See Also:
DatabaseMetaData.getTypeInfo()

getLiteralSuffix

public String getLiteralSuffix()
Description copied from interface: DataType
Suffix used to quote a literal to delimit value for this type when in SQL syntax or result display

Specified by:
getLiteralSuffix in interface DataType
See Also:
DatabaseMetaData.getTypeInfo()

getNullableCode

public int getNullableCode()
Description copied from interface: DataType
Code indicating that type does not accept, does accept, or does not disclose acceptance of null values

Specified by:
getNullableCode in interface DataType
See Also:
DatabaseMetaData.getTypeInfo()

getSearchableCode

public short getSearchableCode()
Description copied from interface: DataType
Code indicating how much WHERE ... LIKE support is available across a column of this type

Specified by:
getSearchableCode in interface DataType
See Also:
DatabaseMetaData.getTypeInfo()

isUnsigned

public boolean isUnsigned()
Description copied from interface: DataType
For numeric types, indicates whether type stores only non-negative (>= 0) values

Specified by:
isUnsigned in interface DataType
See Also:
DatabaseMetaData.getTypeInfo()

supportsSuccessor

public boolean supportsSuccessor()
Description copied from interface: DataType
Returns true if the DataType.successor(java.lang.Object)method is supported, false otherwise.

Specified by:
supportsSuccessor in interface DataType

successor

public Object successor(Object value)
                 throws IllegalArgumentException
Description copied from interface: DataType
Returns the successor for the given value. For example, the successor of the integer 1 is 2.

Specified by:
successor in interface DataType
Throws:
IllegalArgumentException

getPrecisionRadix

public int getPrecisionRadix()
Description copied from interface: DataType
Indicates radix used to compute maximum number of significant digits for this datatype, as returned by DataType.getPrecision().

Specified by:
getPrecisionRadix in interface DataType
Returns:
radix used to compute value of DataType.getPrecision(), typically 2 or 10.

toNumber

protected Number toNumber(Object value)
                   throws AxionException
Throws:
AxionException

toBigDecimal

public BigDecimal toBigDecimal(Object value)
                        throws AxionException
Description copied from interface: DataType
Convert the given non- null value to a BigDecimal, or throw a AxionException.

Specified by:
toBigDecimal in interface DataType
Throws:
AxionException
See Also:
ResultSet.getBigDecimal(int, int)

toBigInteger

public BigInteger toBigInteger(Object value)
                        throws AxionException
Description copied from interface: DataType
Convert the given non- null value to a BigInteger, or throw a AxionException.

Specified by:
toBigInteger in interface DataType
Throws:
AxionException
See Also:
java.sql.ResultSet#getBigInteger

toBoolean

public boolean toBoolean(Object value)
                  throws AxionException
Description copied from interface: DataType
Convert the given non- null value to a boolean, or throw a SQLException.

Specified by:
toBoolean in interface DataType
Throws:
AxionException
See Also:
ResultSet.getBoolean(int)

toByte

public byte toByte(Object value)
            throws AxionException
Description copied from interface: DataType
Convert the given non- null value to a byte, or throw a SQLException.

Specified by:
toByte in interface DataType
Throws:
AxionException
See Also:
ResultSet.getByte(int)

toByteArray

public byte[] toByteArray(Object value)
                   throws AxionException
Description copied from interface: DataType
Convert the given non- null value to a byte[], or throw a AxionException.

Specified by:
toByteArray in interface DataType
Throws:
AxionException
See Also:
ResultSet.getBytes(int)

toDate

public Date toDate(Object value)
            throws AxionException
Description copied from interface: DataType
Convert the given non- null value to a Date, or throw a SQLException.

Specified by:
toDate in interface DataType
Throws:
AxionException
See Also:
ResultSet.getDate(int)

toDouble

public double toDouble(Object value)
                throws AxionException
Description copied from interface: DataType
Convert the given non- null value to a double, or throw a AxionException.

Specified by:
toDouble in interface DataType
Throws:
AxionException
See Also:
ResultSet.getDouble(int)

toFloat

public float toFloat(Object value)
              throws AxionException
Description copied from interface: DataType
Convert the given non- null value to a float, or throw a AxionException.

Specified by:
toFloat in interface DataType
Throws:
AxionException
See Also:
ResultSet.getFloat(int)

toInt

public int toInt(Object value)
          throws AxionException
Description copied from interface: DataType
Convert the given non- null value to a int, or throw a AxionException.

Specified by:
toInt in interface DataType
Throws:
AxionException
See Also:
ResultSet.getInt(int)

toLong

public long toLong(Object value)
            throws AxionException
Description copied from interface: DataType
Convert the given non- null value to a long, or throw a AxionException.

Specified by:
toLong in interface DataType
Throws:
AxionException
See Also:
ResultSet.getLong(int)

toShort

public short toShort(Object value)
              throws AxionException
Description copied from interface: DataType
Convert the given non- null value to a short, or throw a AxionException.

Specified by:
toShort in interface DataType
Throws:
AxionException
See Also:
ResultSet.getShort(int)

toString

public String toString(Object value)
                throws AxionException
Description copied from interface: DataType
Convert the given non- null value to a String, or throw a AxionException.

Specified by:
toString in interface DataType
Throws:
AxionException
See Also:
ResultSet.getString(int)

toURL

public URL toURL(Object value)
          throws AxionException
Description copied from interface: DataType
Convert the given non- null value to a URL, or throw a AxionException.

Specified by:
toURL in interface DataType
Throws:
AxionException
See Also:
ResultSet.getURL(int)

toTime

public Time toTime(Object value)
            throws AxionException
Description copied from interface: DataType
Convert the given non- null value to a Time, or throw a AxionException.

Specified by:
toTime in interface DataType
Throws:
AxionException
See Also:
ResultSet.getTime(int)

toTimestamp

public Timestamp toTimestamp(Object value)
                      throws AxionException
Description copied from interface: DataType
Convert the given non- null value to a Timestamp, or throw a AxionException.

Specified by:
toTimestamp in interface DataType
Throws:
AxionException
See Also:
ResultSet.getTimestamp(int)

toClob

public Clob toClob(Object value)
            throws AxionException
Description copied from interface: DataType
Convert the given non- null value to a Clob, or throw a AxionException.

Specified by:
toClob in interface DataType
Throws:
AxionException
See Also:
ResultSet.getClob(int)

toBlob

public Blob toBlob(Object value)
            throws AxionException
Description copied from interface: DataType
Convert the given non- null value to a Blob, or throw a AxionException.

Specified by:
toBlob in interface DataType
Throws:
AxionException
See Also:
ResultSet.getBlob(int)