org.axiondb.types
Class TimestampType

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

public class TimestampType
extends BaseDataType
implements Comparator

A DataType representing a timestamp value.

Version:
$Revision: 1.29 $ $Date: 2004/09/09 23:47:42 $
See Also:
Serialized Form

Field Summary
static DateFormat[] _fmts
           
static Locale LOCALE
          irrespective of the JVM's Locale lets pick a Locale for use on any JVM
static TimeZone TIMEZONE
           
 
Constructor Summary
TimestampType()
           
 
Method Summary
 boolean accepts(Object value)
          Returns true iff value is null, a Number, or a String that can be converted to a Long.
 int compare(Object left, Object right)
           
 Object convert(Object value)
          Returns an Byte converted from the given value, or throws IllegalArgumentException if the given value isn't acceptable.
protected  Comparator getComparator()
          This base implementation simply returns a ComparableComparator.
 int getJdbcType()
          Returns the JDBC type codemost closely matching this type.
 int getPrecision()
          Value returned by ResultSetMetaData#getPrecisionfor this data type.
 String getPreferredValueClassName()
          Returns the "normal" type returned by convert(java.lang.Object).
static TimeZone getTimeZone()
           
 DataType makeNewInstance()
           
 Object read(DataInput in)
          Instantiate an object of my type from the given DataInput.
static void setTimeZone(String id)
           
 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)
          Writes the given value to the given DataOutput.
 
Methods inherited from class org.axiondb.types.BaseDataType
getColumnDisplaySize, 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
 

Field Detail

LOCALE

public static final Locale LOCALE
irrespective of the JVM's Locale lets pick a Locale for use on any JVM


TIMEZONE

public static TimeZone TIMEZONE

_fmts

public static final DateFormat[] _fmts
Constructor Detail

TimestampType

public TimestampType()
Method Detail

getJdbcType

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

Specified by:
getJdbcType in interface DataType
Specified by:
getJdbcType in class BaseDataType

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
Overrides:
getPreferredValueClassName in class BaseDataType
See Also:
AxionResultSetMetaData.getColumnClassName(int)

toString

public String toString()

getPrecision

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

Specified by:
getPrecision in interface DataType
Overrides:
getPrecision in class BaseDataType

accepts

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

Specified by:
accepts in interface DataType
Specified by:
accepts in class BaseDataType

convert

public Object convert(Object value)
               throws IllegalArgumentException
Returns an Byte converted from the given value, or throws IllegalArgumentException if the given value isn't acceptable.

Specified by:
convert in interface DataType
Specified by:
convert in class BaseDataType
Throws:
IllegalArgumentException

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 BaseDataType
Throws:
AxionException

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 BaseDataType
Throws:
AxionException

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 BaseDataType
Throws:
AxionException

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 BaseDataType
Throws:
AxionException

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 BaseDataType
Throws:
AxionException

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 BaseDataType

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 BaseDataType
Throws:
IllegalArgumentException

read

public 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
Specified by:
read in class BaseDataType
Throws:
IOException
See Also:
write(java.lang.Object, java.io.DataOutput)

write

public void write(Object value,
                  DataOutput out)
           throws IOException
Writes the given value to the given DataOutput. Null values are written as Integer.MIN_VALUE. All other values are written directly with an int representing nanoseconds first, and a long representing the time.

Specified by:
write in interface DataType
Specified by:
write in class BaseDataType
Parameters:
value - the value to write, which must be acceptable
Throws:
IOException

makeNewInstance

public DataType makeNewInstance()
Specified by:
makeNewInstance in interface DataTypeFactory
Specified by:
makeNewInstance in class BaseDataType

compare

public int compare(Object left,
                   Object right)
Specified by:
compare in interface Comparator
Overrides:
compare in class BaseDataType

getComparator

protected Comparator getComparator()
Description copied from class: BaseDataType
This base implementation simply returns a ComparableComparator.

Overrides:
getComparator in class BaseDataType

setTimeZone

public static void setTimeZone(String id)

getTimeZone

public static TimeZone getTimeZone()