com.davisor.data
Class TimestampType

java.lang.Object
  extended byjava.text.Format
      extended bycom.davisor.data.Type
          extended bycom.davisor.data.LocaleType
              extended bycom.davisor.data.FormatType
                  extended bycom.davisor.data.DateFormatType
                      extended bycom.davisor.data.TimestampType
All Implemented Interfaces:
java.lang.Cloneable, java.util.Comparator, com.davisor.core.Dupable, java.io.Serializable
Direct Known Subclasses:
CalendarType, DateType, MomentType, RelativeTimestampType, TimestampInputType, TimestampOutputType, TimeType

public class TimestampType
extends DateFormatType

TimestampType is the base class for all data types that manipulate exact moments of time. As with all the other types, the main function of TimestampType is to convert timestamp strings to timestamp objects and back. Timestamp strings contain date and time-of-day information, formatted by current type format.

Format syntax

Timestamp type inherits it's formatting functionality from it's DateFormatType superclass.

Since:
JDK1.1
See Also:
CalendarFieldType, TimestampData, Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.text.Format
java.text.Format.Field
 
Field Summary
static TimestampType DEFAULT
          Default timestamp type.
static java.lang.String TYPENAME
          Type name ("TIMESTAMP").
 
Fields inherited from class com.davisor.data.DateFormatType
GMT, LOCAL, M_style, M_timeZone
 
Fields inherited from class com.davisor.data.FormatType
M_pattern, M_sample
 
Fields inherited from class com.davisor.data.LocaleType
DEFAULT_LOCALE, M_locale
 
Fields inherited from class com.davisor.data.Type
METADATA_GROUP, METADATA_NAME, METADATA_PARENT, METADATA_SUBCHANNELS
 
Constructor Summary
  TimestampType()
          Default constructor.
  TimestampType(DateFormatType dft)
          Deep copy constructor.
  TimestampType(java.lang.String dataName)
          Creates a new default type with no identity.
  TimestampType(java.lang.String dataName, java.lang.String id, java.util.Map metaData, java.util.Locale locale, java.lang.String pattern, java.lang.Object sample, int style, java.util.TimeZone timeZone)
          Creates a new timestamp type.
  TimestampType(java.lang.String dataName, java.lang.String id, java.lang.String format)
          Creates a new timestamp type with localized timestamp formatting.
protected TimestampType(java.lang.String typeName, java.lang.String dataName, java.lang.String id, java.util.Map metaData, java.util.Locale locale, java.lang.String pattern, java.lang.Object sample, int style, java.util.TimeZone timeZone)
          Creates a new timestamp type.
 
Method Summary
 com.davisor.core.Dupable dup()
          Makes a deep copy of this object.
 boolean equals(java.lang.Object o)
          Tests if this object is equal to another object.
 int getSQLCode()
          Gets the SQL type code, as defined by java.sql.Types.
 DataValue toData(java.sql.CallableStatement statement, int column)
          Converts a callable statement variable to a data value.
 DataValue toData(java.sql.ResultSet resultSet, int column)
          Converts a result set column value to a data value.
 DataValue zero()
          Gets zero data value for this type.
 
Methods inherited from class com.davisor.data.DateFormatType
createCalendar, createCalendar, createCalendar, createCalendar, createCalendar, createCalendar, createFormatter, dateValue, getFormat, getLast, getStyle, getTimeZone, getValueClass, hashCode, setFormat, setStyle, setTimeZone, stringValue, strip, toData, toData, toData, toData
 
Methods inherited from class com.davisor.data.FormatType
clearFormatter, getFormatter, getPattern, getSample, setFormat, setLocale, setPattern, setSample
 
Methods inherited from class com.davisor.data.LocaleType
getLocale, setLocale
 
Methods inherited from class com.davisor.data.Type
ceil, check, check, compare, create, create, create, create, create, dup, floor, format, getCompatibility, getDataName, getId, getID, getMetaData, getMetaData, getSpecs, getSQLName, getSQLName, getTypeName, isNull, parseObject, register, register, setDataName, setId, setID, setMetaData, setMetaData, setSpecs, toString, toXML, xmlEnd, xmlStart
 
Methods inherited from class java.text.Format
clone, format, formatToCharacterIterator, parseObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT

public static final TimestampType DEFAULT
Default timestamp type.


TYPENAME

public static final java.lang.String TYPENAME
Type name ("TIMESTAMP").

See Also:
Constant Field Values
Constructor Detail

TimestampType

public TimestampType()
Default constructor.


TimestampType

public TimestampType(DateFormatType dft)
Deep copy constructor.


TimestampType

public TimestampType(java.lang.String dataName)
Creates a new default type with no identity.

Parameters:
dataName - data name (may be null)

TimestampType

public TimestampType(java.lang.String dataName,
                     java.lang.String id,
                     java.lang.String format)
Creates a new timestamp type with localized timestamp formatting.

This is the constructor the SQL type mapper Type.create(Integer,String,String,String) method will call to create a type that matches given SQL type.

Parameters:
dataName - data name (may be null)
id - type identity (may be null)
format - date format (may be null)
See Also:
DateFormatType.setFormat(java.lang.String)

TimestampType

public TimestampType(java.lang.String dataName,
                     java.lang.String id,
                     java.util.Map metaData,
                     java.util.Locale locale,
                     java.lang.String pattern,
                     java.lang.Object sample,
                     int style,
                     java.util.TimeZone timeZone)
Creates a new timestamp type.

Parameters:
dataName - data name (may be null)
id - type identity (may be null)
metaData - type meta data map (may be null)
locale - type locale (may be null)
pattern - format pattern (may be null)
sample - format sample (may be null)
style - java.text.DateFormat style code
timeZone - date format time zone
See Also:
FormatType.setLocale(java.util.Locale), FormatType.setPattern(java.lang.String), FormatType.setSample(java.lang.Object), DateFormatType.setStyle(int), DateFormatType.setTimeZone(java.util.TimeZone)

TimestampType

protected TimestampType(java.lang.String typeName,
                        java.lang.String dataName,
                        java.lang.String id,
                        java.util.Map metaData,
                        java.util.Locale locale,
                        java.lang.String pattern,
                        java.lang.Object sample,
                        int style,
                        java.util.TimeZone timeZone)
Creates a new timestamp type.

Parameters:
typeName - type name
dataName - data name (may be null)
id - type identity (may be null)
metaData - type meta data map (may be null)
locale - type locale (may be null)
pattern - format pattern (may be null)
sample - format sample (may be null)
style - java.text.DateFormat style code
timeZone - date format time zone
See Also:
FormatType.setLocale(java.util.Locale), FormatType.setPattern(java.lang.String), FormatType.setSample(java.lang.Object), DateFormatType.setStyle(int), DateFormatType.setTimeZone(java.util.TimeZone)
Method Detail

dup

public com.davisor.core.Dupable dup()
Makes a deep copy of this object.

Specified by:
dup in interface com.davisor.core.Dupable
Specified by:
dup in class Type

equals

public boolean equals(java.lang.Object o)
Tests if this object is equal to another object.

Timestamp types are equal if their super-classes are.

Specified by:
equals in interface java.util.Comparator
Overrides:
equals in class DateFormatType
See Also:
FormatType.equals(java.lang.Object)

getSQLCode

public int getSQLCode()
Gets the SQL type code, as defined by java.sql.Types.

Overrides:
getSQLCode in class Type
Returns:
Types.VARCHAR.

toData

public DataValue toData(java.sql.CallableStatement statement,
                        int column)
                 throws InvalidDataException,
                        java.sql.SQLException
Converts a callable statement variable to a data value.

Gets statement timestamp value, and returns a corresponding TimestampData value.

Overrides:
toData in class Type
Parameters:
statement - statement holding the data value to be converted
column - SQL column index for the data value to be converted
Returns:
a data value object corresponding to given object value
Throws:
InvalidDataException - if given object value could not be parsed
java.sql.SQLException - if a SQL error occurs
See Also:
toData(ResultSet,int), TimestampData

toData

public DataValue toData(java.sql.ResultSet resultSet,
                        int column)
                 throws InvalidDataException,
                        java.sql.SQLException
Converts a result set column value to a data value.

Gets result set column timestamp value, and returns a corresponding TimestampData value.

Overrides:
toData in class Type
Parameters:
resultSet - resultSet holding the data value to be converted
column - SQL column index for the data value to be converted
Returns:
a data value object corresponding to given object value
Throws:
InvalidDataException - if given object value could not be parsed
java.sql.SQLException - if a SQL error occurs
See Also:
toData(CallableStatement,int), TimestampData

zero

public DataValue zero()
Gets zero data value for this type.

Specified by:
zero in class Type
Returns:
a new zero value TimestampData object sharing this type
See Also:
DataValue.deinterpolate(com.davisor.data.DataValue, com.davisor.data.DataValue), DataValue.interpolate(double, com.davisor.data.DataValue)


Copyright © 2001-2004 Davisor Oy. All Rights Reserved.