org.jcoderz.phoenix.cmpgen2
Class TypeMapping

java.lang.Object
  extended by org.jcoderz.phoenix.cmpgen2.TypeMapping

public final class TypeMapping
extends Object

Author:
Albrecht Messner

Method Summary
static String getJavaType(ColumnSpec column, boolean fullyQualified)
          Finds the appropriate type mapping from a given column spec.
static String getNumberTypeMapping(String sqlType, int precision, int scale)
          Returns a type mapping for numeric types.
static String getTypeMapping(String sqlType)
          Returns the fully qualified java type to which an SQL type is mapped.
static boolean isPrimitiveType(String type)
          Determines whether a given type is primitive.
static String primitiveToObject(String primitiveType)
          Maps a java primitive type to its corresponding wrapper object.
static String unqualifyType(String typeName)
          Returns everything after the last dot in a type name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getJavaType

public static String getJavaType(ColumnSpec column,
                                 boolean fullyQualified)
                          throws CmpGeneratorException
Finds the appropriate type mapping from a given column spec. Note that the type returned here is the "simple" type as it is stored in the database, not the "complex" type.

Parameters:
column - the column specification
fullyQualified - whether the type should contain the package name or not
Returns:
the simple java type used to store the column in the db
Throws:
CmpGeneratorException - if no type mapping can be found

unqualifyType

public static String unqualifyType(String typeName)
Returns everything after the last dot in a type name.

Parameters:
typeName - a java type name
Returns:
the unqualified type name, or the argument if it was not a qualified java type name

getTypeMapping

public static String getTypeMapping(String sqlType)
Returns the fully qualified java type to which an SQL type is mapped.

Parameters:
sqlType - the name of the sql type
Returns:
the FQ type name of the java type, or null if this method can not find a type mapping

getNumberTypeMapping

public static String getNumberTypeMapping(String sqlType,
                                          int precision,
                                          int scale)
Returns a type mapping for numeric types.

Parameters:
sqlType - the name of the sql type
precision - the precision of the sql type
scale - the scale of the sql type, or 0 if no scale given
Returns:
the name of the appropriate java type

isPrimitiveType

public static boolean isPrimitiveType(String type)
Determines whether a given type is primitive.

Parameters:
type - the name of a java type
Returns:
true if the type is primitive, false otherwise

primitiveToObject

public static String primitiveToObject(String primitiveType)
Maps a java primitive type to its corresponding wrapper object.

Parameters:
primitiveType - the name of a primitive type
Returns:
the corresponding wrapper object
Throws:
IllegalArgumentException - if primitiveType is not a primitive type


Copyright 2007 The jCoderZ Project.