net.sourceforge.sqlunit.types
Class UnsupportedType

java.lang.Object
  extended by net.sourceforge.sqlunit.types.UnsupportedType
All Implemented Interfaces:
java.lang.Comparable, IType
Direct Known Subclasses:
ArrayType, BigDecimalType, BinaryType, BlobType, BooleanType, ByteArrayType, ByteType, ClobType, DateType, DoubleType, FloatType, IntegerType, JavaObjectType, LongType, OracleCursorType, OtherType, ShortType, StringType, TextType, TimestampType, TimeType

public class UnsupportedType
extends java.lang.Object
implements IType

Defines behavior for a type which is not supported by SQLUnit. This also serves as the superclass for all the other types.

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

Constructor Summary
UnsupportedType()
          Default constructor.
 
Method Summary
 int compareTo(java.lang.Object obj)
          Specifies the comparison order for this datatype.
 boolean equals(java.lang.Object obj)
          Returns true if the value of the two types are equal.
protected  java.lang.String format(java.lang.Object obj)
          The formatting hook with default behavior which is meant to be overriden by the subclass.
protected  java.lang.String formatString(java.lang.String obj)
          The formatting hook which gets activated if the passed in Object is a String.
 int getId()
          Returns the SQL Type Code for this type.
 java.lang.String getName()
          Returns the XML name for this type.
 java.lang.Object getValue()
          Returns the stored value for this type as an Object.
 int hashCode()
          Returns the hashcode for the underlying value.
protected  java.lang.Object parse(java.lang.String str)
          The parsing hook with default behavior which is meant to be overriden by the subclass.
 void setId(int id)
          Sets the SQL Type code for this type.
 void setName(java.lang.String name)
          Sets the XML name for this type.
 void setValue(java.lang.Object obj)
          Sets the stored value for this type.
 java.lang.Object toObject(java.lang.String str)
          Converts a String representation of the Object to the Object itself.
 java.lang.String toString(java.lang.Object obj)
          Converts the Object to its String representation.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnsupportedType

public UnsupportedType()
Default constructor.

Method Detail

getName

public final java.lang.String getName()
Returns the XML name for this type.

Specified by:
getName in interface IType
Returns:
the XML name for this type.

setName

public final void setName(java.lang.String name)
Sets the XML name for this type.

Specified by:
setName in interface IType
Parameters:
name - the XML name for this type.

getId

public final int getId()
Returns the SQL Type Code for this type.

Specified by:
getId in interface IType
Returns:
the SQL type code for this type.

setId

public final void setId(int id)
Sets the SQL Type code for this type.

Specified by:
setId in interface IType
Parameters:
id - the SQL Type code for this type.

getValue

public final java.lang.Object getValue()
Returns the stored value for this type as an Object.

Specified by:
getValue in interface IType
Returns:
the stored value of this type.

setValue

public final void setValue(java.lang.Object obj)
Sets the stored value for this type.

Specified by:
setValue in interface IType
Parameters:
obj - the value to store in this type.

toString

public final java.lang.String toString(java.lang.Object obj)
                                throws SQLUnitException
Converts the Object to its String representation. This is called from the result tag when trying to build the DatabaseResult object from the specified result, as well as from the ResultSetBean when trying to build the DatabaseResult from the results of an SQL or stored procedure call. This method abstracts out some common operations that need to be done during this time, and provides hooks for subclasses to provide their own behavior. Each of these hooks also have default behavior, which is provided by this class if not overriden by the subclass.

Specified by:
toString in interface IType
Parameters:
obj - an Object to be converted to String.
Returns:
the String representation of the object.
Throws:
SQLUnitException - if the conversion to String failed.

toObject

public final java.lang.Object toObject(java.lang.String str)
                                throws SQLUnitException
Converts a String representation of the Object to the Object itself. Where provided, this typically uses the parsing methods of the underlying Java type. This is called from the param element when we need to set values of variables for a SQL or stored procedure to execute. This method abstracts out some common operations that need to be done in all subclasses, and provides hooks for subclasses to provide their own behavior. Each of these hooks have default behavior, which is provided by this class if not overriden by the subclass.

Specified by:
toObject in interface IType
Parameters:
str - the String to be converted into an Object.
Returns:
the Object
Throws:
SQLUnitException - if the conversion to Object failed.

compareTo

public int compareTo(java.lang.Object obj)
Specifies the comparison order for this datatype. In this case there is no comparison possible, so it always returns zero. This will be overriden by subclasses.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - the Object to compare against.
Returns:
an int indicating whether this object is less than, equal to or greater than the object passed in.

hashCode

public int hashCode()
Returns the hashcode for the underlying value. This is likely to be overriden by subclasses.

Overrides:
hashCode in class java.lang.Object
Returns:
the hashcode for the underlying value.

equals

public boolean equals(java.lang.Object obj)
Returns true if the value of the two types are equal. This is likely to be overriden by subclasses.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the Object to compare against.
Returns:
true if the values of the two objects are equal.

format

protected java.lang.String format(java.lang.Object obj)
                           throws SQLUnitException
The formatting hook with default behavior which is meant to be overriden by the subclass. This method is called from within toString() after verifying that the Object passed in is not a String and is not null. A setValue() is called before passing control off to this method.

Parameters:
obj - the Object to convert to a String.
Returns:
the String representation of the object.
Throws:
SQLUnitException - if the conversion to String failed.

formatString

protected java.lang.String formatString(java.lang.String obj)
                                 throws SQLUnitException
The formatting hook which gets activated if the passed in Object is a String. Subclasses will typically just do the default behavior, ie, pass it back, but some of them convert the String to MD5 Digest.

Parameters:
obj - the String object.
Returns:
another String object, the contents of which depend on the particular implementation in the subclass. Default behavior is to return the passed in String.
Throws:
SQLUnitException - if there was some problem with formatting.

parse

protected java.lang.Object parse(java.lang.String str)
                          throws SQLUnitException
The parsing hook with default behavior which is meant to be overriden by the subclass. This method is called from within toObject() after verifying that the String is not a "NULL". A setValue() is called in the toObject() after parse() is called.

Parameters:
str - the String to parse into an Object.
Returns:
the Object.
Throws:
SQLUnitException - if the conversion to Object failed.