org.clazzes.jdbc2xml.helper
Class TypesHelper

java.lang.Object
  extended by org.clazzes.jdbc2xml.helper.TypesHelper

public abstract class TypesHelper
extends java.lang.Object

Static helper methods for SQL types.

Author:
wglas

Constructor Summary
TypesHelper()
           
 
Method Summary
static java.lang.String deferrabilityShortToString(short s)
          Parse deferrability string of the deferrability attribute of a foreignkey tag.
static short deferrabilityStringToShort(java.lang.String s)
          Parse deferrability string of the deferrability attribute of a foreignkey tag.
static java.lang.String fkRuleShortToString(short s)
          Parse rule string of a deleteRule or updateRule attribute of a foreignkey tag.
static short fkRuleStringToShort(java.lang.String s)
          Parse a delete/update rule string of a deleteRule or updateRule attribute of a foreignkey tag.
static boolean isNumeric(int type)
           
static boolean isString(int type)
           
static int stringToType(java.lang.String s)
           
static java.lang.String typeToString(int type)
          Convert an SQL type to a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypesHelper

public TypesHelper()
Method Detail

typeToString

public static java.lang.String typeToString(int type)
Convert an SQL type to a string.

Parameters:
type - A constant of Types
Returns:
A string corresponding to the JAVA SQL type constant.

stringToType

public static int stringToType(java.lang.String s)
Parameters:
s - A String representing the JAVA SQL type.
Returns:
The JAVA SQL type constant.If the string is unknown, return Types.OTHER.

isNumeric

public static boolean isNumeric(int type)
Parameters:
type - An JDBC type contant.
Returns:
Whether this type is numeric, i.e. values of this type do not need to be quoted.

isString

public static boolean isString(int type)
Parameters:
type - An JDBC type contant.
Returns:
Whether this type is a string value, i.e. values of this type are not binary not numeric and not of date/time style and are not a large character object (CLOB/LONGVARCHAR).

deferrabilityStringToShort

public static short deferrabilityStringToShort(java.lang.String s)
Parse deferrability string of the deferrability attribute of a foreignkey tag.

Parameters:
s - "NotDeferrable", "InitiallyDeferred" or "InitiallyImmediate".
Returns:
DatabaseMetaData.importedKeyNotDeferrable, DatabaseMetaData.importedKeyInitiallyDeferred or DatabaseMetaData.importedKeyInitiallyImmediate. If s is null or an unrecognized string, the default value DatabaseMetaData.importedKeyNotDeferrable is assumed.

deferrabilityShortToString

public static java.lang.String deferrabilityShortToString(short s)
Parse deferrability string of the deferrability attribute of a foreignkey tag.

Parameters:
s - DatabaseMetaData.importedKeyNotDeferrable, DatabaseMetaData.importedKeyInitiallyDeferred or DatabaseMetaData.importedKeyInitiallyImmediate.
Returns:
"NotDeferrable", "InitiallyDeferred" or "InitiallyImmediate". If s is an unrecognized integer, the default value "NotDeferrable" is assumed.

fkRuleStringToShort

public static short fkRuleStringToShort(java.lang.String s)
Parse a delete/update rule string of a deleteRule or updateRule attribute of a foreignkey tag.

Parameters:
s - "NoAction", "Cascade", "Restrict", "SetDefault" or "SetNull".
Returns:
DatabaseMetaData.importedKeyNoAction, DatabaseMetaData.importedKeyCascade, DatabaseMetaData.importedKeyRestrict, DatabaseMetaData.importedKeySetDefault or DatabaseMetaData.importedKeySetNull. If s is null or an unrecognized string, the default value DatabaseMetaData.importedKeyNoAction is assumed.

fkRuleShortToString

public static java.lang.String fkRuleShortToString(short s)
Parse rule string of a deleteRule or updateRule attribute of a foreignkey tag.

Parameters:
s - DatabaseMetaData.importedKeyNoAction, DatabaseMetaData.importedKeyCascade, DatabaseMetaData.importedKeyRestrict, DatabaseMetaData.importedKeySetDefault or DatabaseMetaData.importedKeySetNull.
Returns:
"NoAction", "Cascade", "Restrict", "SetDefault" or "SetNull". If s is an unrecognized integer, the default value "NoAction" is assumed.


Copyright © 2007. All Rights Reserved.