java.lang.Object
org.eclipse.persistence.internal.databaseaccess.FieldTypeDefinition
All Implemented Interfaces:
Serializable

public class FieldTypeDefinition extends Object implements Serializable
INTERNAL: Purpose: Define a database platform specific definition for a platform independent 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.
See Also:
  • Field Details

    • name

      protected String name
    • defaultSize

      protected int defaultSize
    • defaultSubSize

      protected int defaultSubSize
    • isSizeAllowed

      protected boolean isSizeAllowed
    • isSizeRequired

      protected boolean isSizeRequired
    • maxPrecision

      protected int maxPrecision
    • minScale

      protected int minScale
    • maxScale

      protected int maxScale
    • shouldAllowNull

      protected boolean shouldAllowNull
    • typesuffix

      protected String typesuffix
  • Constructor Details

    • FieldTypeDefinition

      public FieldTypeDefinition()
    • FieldTypeDefinition

      public FieldTypeDefinition(String databaseTypeName)
      Return a new field type.
      See Also:
    • FieldTypeDefinition

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

      public FieldTypeDefinition(String databaseTypeName, int defaultSize, int defaultSubSize)
      Return a new field type with a required size defaulting to the defaultSize.
    • FieldTypeDefinition

      public FieldTypeDefinition(String databaseTypeName, int defaultSize, String aTypesuffix)
    • FieldTypeDefinition

      public FieldTypeDefinition(String databaseTypeName, boolean allowsSize)
      Return a new field type with a required size defaulting to the defaultSize.
    • FieldTypeDefinition

      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.
  • Method Details

    • getDefaultSize

      public int getDefaultSize()
      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.
    • getDefaultSubSize

      public int getDefaultSubSize()
      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.
    • getMaxPrecision

      public int getMaxPrecision()
    • getMaxScale

      public int getMaxScale()
    • getMinScale

      public int getMinScale()
    • getName

      public String getName()
      Return the name. Can be any database primitive type name, this name will then be mapped to the Java primitive type, the database 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 Also:
    • getTypesuffix

      public String getTypesuffix()
      Returns a type suffix (like unicode, byte or ascii) for maxdb create table stmts
    • isSizeAllowed

      public boolean isSizeAllowed()
      Return if this type can support a size specification.
    • isSizeRequired

      public boolean isSizeRequired()
      Return if this type must have a size specification.
    • shouldAllowNull

      public boolean shouldAllowNull()
      Return if this type is allowed to be null for this platform
    • setDefaultSize

      public void setDefaultSize(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.
    • setDefaultSubSize

      public void setDefaultSubSize(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.
    • setIsSizeAllowed

      public void setIsSizeAllowed(boolean aBoolean)
      Set if this type can support a size specification.
    • setIsSizeRequired

      public void setIsSizeRequired(boolean aBoolean)
      Set if this type must have a size specification.
    • setShouldAllowNull

      public void setShouldAllowNull(boolean allowsNull)
      Set if this type is allowed to be null for this platform
    • setLimits

      public FieldTypeDefinition setLimits(int maxPrecision, int minScale, int maxScale)
      Set the maximum precision and the minimum and maximum scale.
      Returns:
      this Allowing the method to be invoked inline with constructor
    • setMaxPrecision

      public void setMaxPrecision(int maximum)
    • setMaxScale

      public void setMaxScale(int maximum)
    • setMinScale

      public void setMinScale(int minimum)
    • setName

      public void setName(String name)
      Set the name.
      Parameters:
      name - can be any database primitive type name, this name will then be mapped to the Java primitive type, the database 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 Also:
    • setSizeDisallowed

      public void setSizeDisallowed()
      Set this type to not allow a size specification.
    • setSizeOptional

      public void setSizeOptional()
      Set this type to optionally have a size specification.
    • setSizeRequired

      public void setSizeRequired()
      Set this type to require to have a size specification.
    • toString

      public String toString()
      Overrides:
      toString in class Object