net.sourceforge.sqlunit
Class TypeMapper

java.lang.Object
  extended by net.sourceforge.sqlunit.TypeMapper

public final class TypeMapper
extends java.lang.Object

Reads in the type resource files and provides methods to look up type class names using various keys. This is a Singleton object and will be lazily instantiated once per run.

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

Method Summary
static java.util.List findAllTypeNames(boolean showSupported)
          Convenience method currently used for JUnit testing.
static java.lang.String findClassById(int id)
          Returns the class name for the specified type code.
static java.lang.String findClassByName(java.lang.String name)
          Returns the class name for the specified type name.
static int findIdByName(java.lang.String name)
          Returns the type code for the specified type name.
static java.lang.String findNameById(int id)
          Returns the type name for the specified type code.
static TypeMapper getTypeMapper()
          Returns the current instance of the TypeMapper object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getTypeMapper

public static TypeMapper getTypeMapper()
Returns the current instance of the TypeMapper object.

Returns:
the instance of the TypeMapper object.

findClassByName

public static java.lang.String findClassByName(java.lang.String name)
Returns the class name for the specified type name. If the name is already specified with server name, then restrict lookup to the fully qualified type. Else first lookup the name with the implicit server name returned from the connection, and if that fails look up the basic data type.

Parameters:
name - the type name that is used in the XML file.
Returns:
the full class name for the type class.

findClassById

public static java.lang.String findClassById(int id)
Returns the class name for the specified type code. Extracts the name with findNameById() and then delegates to findClassById().

Parameters:
id - the SQL type code.
Returns:
the full class name for the type class.

findNameById

public static java.lang.String findNameById(int id)
Returns the type name for the specified type code. The id may not be unique by itself, but the id would be unique for a given server, or only among basic datatype if server is not supplied.

Parameters:
id - the SQL type code.
Returns:
the XML type name.

findIdByName

public static int findIdByName(java.lang.String name)
Returns the type code for the specified type name. If the name contains an explicit server name, then it does an exact lookup of the id for the server.typename. Else, it first attempts to lookup an override using the value of the server name from the Connection, and if not found, it falls back on the lookup for basic datatype mappings.

Parameters:
name - the XML type name.
Returns:
the SQL type code.

findAllTypeNames

public static java.util.List findAllTypeNames(boolean showSupported)
Convenience method currently used for JUnit testing. May be used elsewhere later.

Parameters:
showSupported - if true, will show only currently supported types, else will show all the currently configured types.
Returns:
a List of XML names of the currently supported types.