org.apache.beehive.controls.system.jdbc
Class TypeMappingsFactory

Object
  extended by TypeMappingsFactory

public final class TypeMappingsFactory
extends Object

Currently contains all types of type mappings. Implemented using singleton pattern.


Field Summary
static int TYPE_UNKNOWN
           
 
Method Summary
 int convertStringToSQLType(String type)
          Convert a type string to its SQL Type int value.
 Object fixNull(Class type)
          Returns a primitive legal value as opposed to null if type is primitive.
static TypeMappingsFactory getInstance()
          Get an instance of this class.
 int getSqlType(Class classType)
          Get the SQL type of a class, start at top level class an check all super classes until match is found.
 int getSqlType(Object o)
          Get the SQL type for an object.
 int getTypeId(Class classType)
          Get the type id (defined by this class) for the given class.
 Object lookupType(Object val, Object[] args)
           
static Object[] toObjectArray(Object o)
          Create an Object array for the given array.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_UNKNOWN

public static final int TYPE_UNKNOWN
See Also:
Constant Field Values
Method Detail

getInstance

public static TypeMappingsFactory getInstance()
Get an instance of this class.

Returns:
TypeMappingsFactory instance.

convertStringToSQLType

public int convertStringToSQLType(String type)
Convert a type string to its SQL Type int value.

Parameters:
type - A String containing the SQL type name.
Returns:
The SQL type, TYPE_UNKNOWN if cannot convert.

getSqlType

public int getSqlType(Class classType)
Get the SQL type of a class, start at top level class an check all super classes until match is found.

Parameters:
classType - Class to get SQL type of.
Returns:
Types.OTHER if cannot find SQL type.

getSqlType

public int getSqlType(Object o)
Get the SQL type for an object.

Parameters:
o - Object to get SQL type of.
Returns:
SQL type of the object, Types.OTHER if cannot classify.

lookupType

public Object lookupType(Object val,
                         Object[] args)
                  throws IllegalAccessException,
                         InvocationTargetException
Parameters:
val -
args -
Returns:
the type
Throws:
IllegalAccessException
InvocationTargetException

getTypeId

public int getTypeId(Class classType)
Get the type id (defined by this class) for the given class.

Parameters:
classType - Class to get type of.
Returns:
Type id of class.

fixNull

public Object fixNull(Class type)
Returns a primitive legal value as opposed to null if type is primitive.

Parameters:
type - type to get null value for.
Returns:
null value for specifed type.

toObjectArray

public static Object[] toObjectArray(Object o)
Create an Object array for the given array.

Parameters:
o - An array.
Returns:
A new object array.