FileDocCategorySizeDatePackage
FieldTypeDefinition.javaAPI DocGlassfish v2 API10611Tue May 22 16:54:22 BST 2007oracle.toplink.essentials.internal.databaseaccess

FieldTypeDefinition

public class FieldTypeDefinition extends Object implements Serializable
INTERNAL: Purpose: Define a database platform specific definition for a platform independant Java class type. This is used for the field creation within a table creation statement.

Responsibilities:

  • Store a default size and know if the size option is required or optional.
  • Store the name of the real database type.
  • Maintain maximum precision and optionall min & max Scale.

Fields Summary
protected String
name
protected int
defaultSize
protected int
defaultSubSize
protected boolean
isSizeAllowed
protected boolean
isSizeRequired
protected int
maxPrecision
protected int
minScale
protected int
maxScale
protected boolean
shouldAllowNull
Constructors Summary
public FieldTypeDefinition()

        defaultSize = 10;
        isSizeRequired = false;
        isSizeAllowed = true;
        maxPrecision = 10;
        minScale = 0;
        maxScale = 0;
        shouldAllowNull = true;
    
public FieldTypeDefinition(String databaseTypeName)
Return a new field type.

see
#setName()

        this();
        name = databaseTypeName;
    
public FieldTypeDefinition(String databaseTypeName, int defaultSize)
Return a new field type with a required size defaulting to the defaultSize.

        this();
        this.name = databaseTypeName;
        this.defaultSize = defaultSize;
        this.isSizeRequired = true;
        setMaxPrecision(defaultSize);
    
public FieldTypeDefinition(String databaseTypeName, int defaultSize, int defaultSubSize)
Return a new field type with a required size defaulting to the defaultSize.

        this();
        this.name = databaseTypeName;
        this.defaultSize = defaultSize;
        this.defaultSubSize = defaultSubSize;
        this.isSizeRequired = true;
        setMaxPrecision(defaultSize);
        setMaxScale(defaultSubSize);
    
public FieldTypeDefinition(String databaseTypeName, boolean allowsSize)
Return a new field type with a required size defaulting to the defaultSize.

        this();
        this.name = databaseTypeName;
        this.isSizeAllowed = allowsSize;
    
public FieldTypeDefinition(String databaseTypeName, boolean allowsSize, boolean allowsNull)
Return a new field type with a required size defaulting to the defaultSize and shouldAllowNull set to allowsNull.

        this(databaseTypeName, allowsSize);
        this.shouldAllowNull = allowsNull;
    
Methods Summary
public intgetDefaultSize()
Return the default size for this type. This default size will be used if the database requires specification of a size, and the table definition did not provide one.

        return defaultSize;
    
public intgetDefaultSubSize()
Return the default sub-size for this type. This default size will be used if the database requires specification of a size, and the table definition did not provide one.

        return defaultSubSize;
    
public intgetMaxPrecision()

        return maxPrecision;
    
public intgetMaxScale()

        return maxScale;
    
public intgetMinScale()

        return minScale;
    
public java.lang.StringgetName()
Return the name.

param
name can be any database primitive type name, this name will then be mapped to the Java primitive type, the datbase type varies by platform and the mappings can be found in the subclasses of DatabasePlatform. these Java names and their ODBC mappings include; - Integer -> SQL_INT - Float -> SQL_FLOAT - Double -> SQL_DOUBLE - Long -> SQL_LONG - Short -> SQL_INT - BigDecimal -> SQL_NUMERIC - BigInteger -> SQL_NUMERIC - String -> SQL_VARCHAR - Array -> BLOB - Character[] -> SQL_CHAR - Boolean -> SQL_BOOL - Text -> CLOB - Date -> SQL_DATE - Time -> SQL_TIME - Timestamp -> SQL_TIMESTAMP
see
oracle.toplink.essentials.internal.databaseaccess.DatabasePlatform

        return name;
    
public booleanisSizeAllowed()
Return if this type can support a size specification.

        return isSizeAllowed;
    
public booleanisSizeRequired()
Return if this type must have a size specification.

        return isSizeRequired;
    
public voidsetDefaultSize(int defaultSize)
Set the default size for this type. This default size will be used if the database requires specification of a size, and the table definition did not provide one.

        this.defaultSize = defaultSize;
    
public voidsetDefaultSubSize(int defaultSubSize)
Set the default sub-size for this type. This default size will be used if the database requires specification of a size, and the table definition did not provide one.

        this.defaultSubSize = defaultSubSize;
    
public voidsetIsSizeAllowed(boolean aBoolean)
Set if this type can support a size specification.

        isSizeAllowed = aBoolean;
    
public voidsetIsSizeRequired(boolean aBoolean)
Set if this type must have a size specification.

        isSizeRequired = aBoolean;
    
public oracle.toplink.essentials.internal.databaseaccess.FieldTypeDefinitionsetLimits(int maxPrecision, int minScale, int maxScale)
Set the maximum precision and the minimum and maximum scale.

return
this Allowing the method to be invoked inline with constructor

        setMaxPrecision(maxPrecision);
        setMinScale(minScale);
        setMaxScale(maxScale);
        return this;
    
public voidsetMaxPrecision(int maximum)

        maxPrecision = maximum;
    
public voidsetMaxScale(int maximum)

        maxScale = maximum;
    
public voidsetMinScale(int minimum)

        minScale = minimum;
    
public voidsetName(java.lang.String name)
Set the name.

param
name can be any database primitive type name, this name will then be mapped to the Java primitive type, the datbase type varies by platform and the mappings can be found in the subclasses of DatabasePlatform. these Java names and their ODBC mappings include; - Integer -> SQL_INT - Float -> SQL_FLOAT - Double -> SQL_DOUBLE - Long -> SQL_LONG - Short -> SQL_INT - BigDecimal -> SQL_NUMERIC - BigInteger -> SQL_NUMERIC - String -> SQL_VARCHAR - Array -> BLOB - Character[] -> SQL_CHAR - Boolean -> SQL_BOOL - Text -> CLOB - Date -> SQL_DATE - Time -> SQL_TIME - Timestamp -> SQL_TIMESTAMP
see
oracle.toplink.essentials.internal.databaseaccess.DatabasePlatform

        this.name = name;
    
public voidsetShouldAllowNull(boolean allowsNull)
Set if this type is allowed to be null for this platform

        this.shouldAllowNull = allowsNull;
    
public voidsetSizeDisallowed()
Set this type to not allow a size specification.

        setIsSizeAllowed(false);
    
public voidsetSizeOptional()
Set this type to optionally have a size specification.

        setIsSizeRequired(false);
        setIsSizeAllowed(true);
    
public voidsetSizeRequired()
Set this type to require to have a size specification.

        setIsSizeRequired(true);
    
public booleanshouldAllowNull()
Return if this type is allowed to be null for this platform

        return this.shouldAllowNull;
    
public java.lang.StringtoString()

        return Helper.getShortClassName(getClass()) + "(" + getName() + ")";