com.davisor.data
Class TimeType

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
                          extended bycom.davisor.data.TimeType
All Implemented Interfaces:
java.lang.Cloneable, java.util.Comparator, com.davisor.core.Dupable, java.io.Serializable
Direct Known Subclasses:
TimeOutputType

public class TimeType
extends TimestampType

TimeType defines a data type that formats and parses time strings. Time strings are not expected to contain any date information, as opposed to the more general time interpretation used by the Java Time class.

Format syntax

Time type inherits it's formatting functionality from it's DateFormatType superclass. However, time types are expected to be handle only time and no date related information.

Since:
JDK1.1
See Also:
CalendarFieldType, CalendarType, DateType, TimeData, Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.text.Format
java.text.Format.Field
 
Field Summary
static TimeType DEFAULT
          Default time type.
static java.lang.String TYPENAME
          Type name ("TIME").
 
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
  TimeType()
          Default constructor.
  TimeType(java.lang.String dataName)
          Creates a new default type with no identity.
  TimeType(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 date type.
  TimeType(java.lang.String dataName, java.lang.String id, java.lang.String format)
          Create a new time type with localized time formatting.
protected TimeType(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 date type.
  TimeType(TimeType tt)
          Copy constructor.
 
Method Summary
protected  java.text.Format createFormatter()
          Creates a new date format instance suitable for the purposes of this class.
 com.davisor.core.Dupable dup()
          Makes a deep copy of this object.
 boolean equals(java.lang.Object o)
          Tests if this object is equal with another object.
 int getSQLCode()
          Gets the SQL type code, as defined by java.sql.Types.
 java.lang.String stringValue(java.util.Date value)
          Formats a date as a time string.
 void strip(java.util.Calendar calendar)
          Clears all date information from the given calendar.
 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.
 
Methods inherited from class com.davisor.data.TimestampType
zero
 
Methods inherited from class com.davisor.data.DateFormatType
createCalendar, createCalendar, createCalendar, createCalendar, createCalendar, createCalendar, dateValue, getFormat, getLast, getStyle, getTimeZone, getValueClass, hashCode, setFormat, setStyle, setTimeZone, 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 TimeType DEFAULT
Default time type.


TYPENAME

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

See Also:
Constant Field Values
Constructor Detail

TimeType

public TimeType()
Default constructor.


TimeType

public TimeType(TimeType tt)
Copy constructor.


TimeType

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

Parameters:
dataName - data name (may be null)

TimeType

public TimeType(java.lang.String dataName,
                java.lang.String id,
                java.lang.String format)
Create a new time type with localized time 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)

TimeType

public TimeType(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 date 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)

TimeType

protected TimeType(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 date 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

strip

public void strip(java.util.Calendar calendar)
Clears all date information from the given calendar. The result will be a timestamp value that represents a point in time during the calendar default epoch day.

The following calendar fields are cleared:

Overrides:
strip in class DateFormatType
Parameters:
calendar - calendar to be stripped
See Also:
DateType.strip(java.util.Calendar)

dup

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

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

createFormatter

protected java.text.Format createFormatter()
Creates a new date format instance suitable for the purposes of this class.

This particular implementation returns a java.text.DateFormat time instance that is expected to format dates so that they contain only time and no date information. Current pattern is applied to it only if it is also a SimpleDateFormat instance. The format time zone is set to the system default time zone.

Overrides:
createFormatter in class DateFormatType
See Also:
DateFormatType.getTimeZone(), DateType.createFormatter(), DateFormatType.createFormatter()

equals

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

Time types are equal if their super-classes are.

Specified by:
equals in interface java.util.Comparator
Overrides:
equals in class TimestampType

stringValue

public java.lang.String stringValue(java.util.Date value)
Formats a date as a time string. The string is formatted with the current type format, retrived with FormatType.getFormatter(). If the current format is null, java.sql.Time formatting is used.

Overrides:
stringValue in class DateFormatType
Parameters:
value - time value
Returns:
String representation of 'value', formatted according to the current time format. If the value is null or the time of value is TimestampData.NaT, the return value is an empty string.
See Also:
FormatType.getFormatter(), LocaleType.setFormat(java.lang.String)

getSQLCode

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

Overrides:
getSQLCode in class TimestampType

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 time value, and returns a corresponding TimeData value.

Overrides:
toData in class TimestampType
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:
DateFormatType.toData(Object), toData(ResultSet,int), DateFormatType.toData(String,ParsePosition), TimeData

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 time value, and returns a corresponding TimeData value.

Overrides:
toData in class TimestampType
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), DateFormatType.toData(Object), DateFormatType.toData(String,ParsePosition), TimeData


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