org.axiondb.types
Class DateType

java.lang.Object
  extended byorg.axiondb.types.BaseDataType
      extended byorg.axiondb.types.TimestampType
          extended byorg.axiondb.types.DateType
All Implemented Interfaces:
Comparator, DataType, DataTypeFactory, Serializable

public class DateType
extends TimestampType

Implements a date type which can generate instances of java.sql.Date and other JDBC date-related types.

Version:
$Revision: 1.4 $
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.axiondb.types.TimestampType
_fmts, LOCALE, TIMEZONE
 
Constructor Summary
DateType()
           
 
Method Summary
 boolean accepts(Object value)
          Returns true iff value is null, a Number, or a String that can be converted to a Long.
 Object convert(Object value)
          Returns a java.sql.Date converted from the given value , or throws IllegalArgumentExceptionif the given value isn't acceptable.
 int getColumnDisplaySize()
          Value returned by ResultSetMetaData#getColumnDisplaySizefor this data type.
 int getJdbcType()
          Returns the JDBC type codemost closely matching this type.
 DataType makeNewInstance()
           
static long normalizeToUTCZeroHour(long rawTimeMillis)
           
 Object read(DataInput in)
          Overrides parent implementation to read only milliseconds (as a long) from the input stream, ignoring any nanoseconds written by TimestampType.write().
 Object successor(Object value)
          Returns the successor for the given value.
 boolean supportsSuccessor()
          Returns true if the 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.
 Date toDate(Object value)
          Convert the given non- null value to a Date, or throw a SQLException.
 String toString()
           
 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.
 void write(Object value, DataOutput out)
          Overrides parent implementation to always write time (in milliseconds) as a long, writing a placeholder zero for the nanosecond field usually written by TimestampType.write().
 
Methods inherited from class org.axiondb.types.TimestampType
compare, getComparator, getPrecision, getPreferredValueClassName, getTimeZone, setTimeZone
 
Methods inherited from class org.axiondb.types.BaseDataType
getLiteralPrefix, getLiteralSuffix, getNullableCode, getScale, getSearchableCode, isCaseSensitive, isCurrency, isUnsigned, toBigInteger, toBlob, toBoolean, toByte, toByteArray, toClob, toDouble, toFloat, toInt, toLong, toNumber, toShort, toURL
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

DateType

public DateType()
Method Detail

normalizeToUTCZeroHour

public static long normalizeToUTCZeroHour(long rawTimeMillis)

accepts

public boolean accepts(Object value)
Description copied from class: TimestampType
Returns true iff value is null, a Number, or a String that can be converted to a Long.

Specified by:
accepts in interface DataType
Overrides:
accepts in class TimestampType
See Also:
DataType.accepts(java.lang.Object)

convert

public Object convert(Object value)
               throws IllegalArgumentException
Returns a java.sql.Date converted from the given value , or throws IllegalArgumentExceptionif the given value isn't acceptable.

Specified by:
convert in interface DataType
Overrides:
convert in class TimestampType
Throws:
IllegalArgumentException

getColumnDisplaySize

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

Specified by:
getColumnDisplaySize in interface DataType
Overrides:
getColumnDisplaySize in class BaseDataType
See Also:
DataType.getColumnDisplaySize()

getJdbcType

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

Specified by:
getJdbcType in interface DataType
Overrides:
getJdbcType in class TimestampType
See Also:
DataType.getJdbcType()

makeNewInstance

public DataType makeNewInstance()
Specified by:
makeNewInstance in interface DataTypeFactory
Overrides:
makeNewInstance in class TimestampType
See Also:
DataTypeFactory.makeNewInstance()

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
Overrides:
successor in class TimestampType
Throws:
IllegalArgumentException
See Also:
DataType.successor(java.lang.Object)

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
Overrides:
supportsSuccessor in class TimestampType
See Also:
DataType.supportsSuccessor()

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
Overrides:
toBigDecimal in class TimestampType
Throws:
AxionException
See Also:
DataType.toBigDecimal(java.lang.Object)

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
Overrides:
toDate in class TimestampType
Throws:
AxionException
See Also:
DataType.toDate(java.lang.Object)

toString

public String toString()
Overrides:
toString in class TimestampType
See Also:
Object.toString()

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
Overrides:
toString in class TimestampType
Throws:
AxionException
See Also:
DataType.toString(java.lang.Object)

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
Overrides:
toTime in class TimestampType
Throws:
AxionException
See Also:
DataType.toTime(java.lang.Object)

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
Overrides:
toTimestamp in class TimestampType
Throws:
AxionException
See Also:
DataType.toTimestamp(java.lang.Object)

read

public Object read(DataInput in)
            throws IOException
Overrides parent implementation to read only milliseconds (as a long) from the input stream, ignoring any nanoseconds written by TimestampType.write(). We read TimeType data assuming that they are in the same form as that of TimestampType data in order to preserve backwards compatibility, as java.sql.Time was originally mapped to TimestampType.

Specified by:
read in interface DataType
Overrides:
read in class TimestampType
Throws:
IOException - if error occurs during read
See Also:
DataType.read(java.io.DataInput)

write

public void write(Object value,
                  DataOutput out)
           throws IOException
Overrides parent implementation to always write time (in milliseconds) as a long, writing a placeholder zero for the nanosecond field usually written by TimestampType.write().

Specified by:
write in interface DataType
Overrides:
write in class TimestampType
Parameters:
value - Date object (typically a java.sql.Date or other convertible form) to be persisted
out - DataOutput to receive serialized data
Throws:
IOException - if error occurs during write
See Also:
DataType.write(java.lang.Object, java.io.DataOutput)