net.sourceforge.sqlunit.types
Class DateType

java.lang.Object
  extended by net.sourceforge.sqlunit.types.UnsupportedType
      extended by net.sourceforge.sqlunit.types.DateType
All Implemented Interfaces:
java.lang.Comparable, IType

public class DateType
extends UnsupportedType

Models a DATE type.

Version:
$Revision: 1.10 $
Author:
Ralph Brendler (rbrendler@users.sourceforge.net), Sujit Pal (spal@users.sourceforge.net)

Field Summary
protected static java.lang.String PATTERN
          Specifies the pattern for the DATE object.
 
Constructor Summary
DateType()
           
 
Method Summary
 int compareTo(java.lang.Object obj)
          Returns a negative, zero or positive number according to whether this object is smaller, equal or larger than the passed in object.
 boolean equals(java.lang.Object obj)
          Returns true if Object obj is the same as this object, else false.
protected  java.lang.String format(java.lang.Object obj)
          Formats a DATE into its String representation.
 int hashCode()
          The hashcode for this object, returns the hashcode for the wrapped java.sql.Date object.
protected  java.lang.Object parse(java.lang.String str)
          Parses a String representing a DATE to a java.sql.Date.
 
Methods inherited from class net.sourceforge.sqlunit.types.UnsupportedType
formatString, getId, getName, getValue, setId, setName, setValue, toObject, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATTERN

protected static java.lang.String PATTERN
Specifies the pattern for the DATE object. This may be overriden in subclasses to work with alternate formats for dates in different databases.

Constructor Detail

DateType

public DateType()
Method Detail

format

protected java.lang.String format(java.lang.Object obj)
                           throws SQLUnitException
Formats a DATE into its String representation.

Overrides:
format in class UnsupportedType
Parameters:
obj - an Object to be converted to the IType interface.
Returns:
the String representation of the object.
Throws:
SQLUnitException - if the formatting failed.

parse

protected java.lang.Object parse(java.lang.String str)
                          throws SQLUnitException
Parses a String representing a DATE to a java.sql.Date.

Overrides:
parse in class UnsupportedType
Parameters:
str - the String representation of the DATE.
Returns:
a java.sql.Date object.
Throws:
SQLUnitException - if the parsing failed.

equals

public final boolean equals(java.lang.Object obj)
Returns true if Object obj is the same as this object, else false.

Overrides:
equals in class UnsupportedType
Parameters:
obj - the Object to compare with.
Returns:
true or false.

hashCode

public final int hashCode()
The hashcode for this object, returns the hashcode for the wrapped java.sql.Date object.

Overrides:
hashCode in class UnsupportedType
Returns:
the hashcode for the underlying Date object.

compareTo

public final int compareTo(java.lang.Object obj)
Returns a negative, zero or positive number according to whether this object is smaller, equal or larger than the passed in object.

Specified by:
compareTo in interface java.lang.Comparable
Overrides:
compareTo in class UnsupportedType
Parameters:
obj - an Object of type DateType.
Returns:
a negative, zero or positive number.