com.davisor.data
Class DateType

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.DateType
All Implemented Interfaces:
java.lang.Cloneable, java.util.Comparator, com.davisor.core.Dupable, java.io.Serializable
Direct Known Subclasses:
DateInputType, DateOutputType

public class DateType
extends TimestampType

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

Format syntax

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

Since:
JDK1.1
See Also:
CalendarFieldType, CalendarType, DateData, TimeType, Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.text.Format
java.text.Format.Field
 
Field Summary
static DateType DEFAULT
          Default date type.
static java.lang.String TYPENAME
          Type name ("DATE").
 
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
  DateType()
          Default constructor.
  DateType(DateType dt)
          Copy constructor.
  DateType(java.lang.String dataName)
          Creates a new default type with no identity.
  DateType(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.
  DateType(java.lang.String dataName, java.lang.String id, java.lang.String format)
          Create a new date type with localized date formatting.
protected DateType(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.
 
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 date string.
 void strip(java.util.Calendar calendar)
          Clears all time 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 DateType DEFAULT
Default date type.


TYPENAME

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

See Also:
Constant Field Values
Constructor Detail

DateType

public DateType()
Default constructor.


DateType

public DateType(DateType dt)
Copy constructor.


DateType

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

Parameters:
dataName - data name (may be null)

DateType

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

DateType

public DateType(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)

DateType

protected DateType(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 time information from the given calendar. The result will be a calendar that represents a date at the moment that the date has just changed.

The following calendar fields are cleared:

Overrides:
strip in class DateFormatType
Parameters:
calendar - calendar to be stripped
See Also:
TimeType.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 date instance that is expected to format dates so that they contain only date and no time 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(), TimeType.createFormatter(), DateFormatType.createFormatter()

equals

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

Date 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 date string. The string is formatted with the current type format, retrived with FormatType.getFormatter(). If the current format is null, java.sql.Date formatting is used.

Overrides:
stringValue in class DateFormatType
Parameters:
value - date value
Returns:
a date string representation of value. If the value is null or the time of value is TimestampData.NaT, the return value is an empty string.
See Also:
FormatType.getFormatter()

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 date value, and returns a corresponding DateData 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 corredponding 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), DataValue.toString(), DateData

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 date value, and returns a corresponding DateData 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 corredponding 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), DataValue.toString(), DateData


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