org.apache.ddlutils
Class PlatformInfo

java.lang.Object
  extended byorg.apache.ddlutils.PlatformInfo

public class PlatformInfo
extends Object

Conatains information about the database platform such as supported features and native type mappings.

Version:
$Revision: 289996 $
Author:
Thomas Dudziak

Constructor Summary
PlatformInfo()
          Creates a new platform info object.
 
Method Summary
 void addDefaultSize(int jdbcTypeCode, int defaultSize)
          Adds a default size for the given jdbc type.
 void addDefaultSize(String jdbcTypeName, int defaultSize)
          Adds a default size for the given jdbc type.
 void addNativeTypeMapping(int jdbcTypeCode, String nativeType)
          Adds a mapping from jdbc type to database-native type.
 void addNativeTypeMapping(int jdbcTypeCode, String nativeType, int targetJdbcTypeCode)
          Adds a mapping from jdbc type to database-native type.
 void addNativeTypeMapping(String jdbcTypeName, String nativeType)
          Adds a mapping from jdbc type to database-native type.
 void addNativeTypeMapping(String jdbcTypeName, String nativeType, String targetJdbcTypeName)
          Adds a mapping from jdbc type to database-native type.
 boolean getCanReadAutoIncrementStatus()
          Determines whether the platform is able to read the auto-increment status for columns from an existing database.
 String getCommentPrefix()
          Returns the string that denotes the beginning of a comment.
 String getCommentSuffix()
          Returns the string that denotes the end of a comment.
 Integer getDefaultSize(int jdbcTypeCode)
          Returns the default size value for the given type, if any.
 String getDelimiterToken()
          Returns the text that is used to delimit identifiers (eg.
 int getMaxIdentifierLength()
          Returns the maximum length of identifiers that this database allows.
 String getNativeType(int typeCode)
          Returns the database-native type for the given type code.
 String getSqlCommandDelimiter()
          Returns the text separating individual sql commands.
 int getTargetJdbcType(int typeCode)
          Returns the jdbc type corresponding to the native type that is used for the given jdbc type.
 String getValueQuoteToken()
          Returns the text that is used for for quoting values (e.g.
 boolean hasNullDefault(int sqlTypeCode)
          Determines whether the native type for the given sql type code (one of the Types constants) has a null default value on this platform.
 boolean hasPrecisionAndScale(int sqlTypeCode)
          Determines whether the native type for the given sql type code (one of the Types constants) has precision and scale specifications on this platform.
 boolean hasSize(int sqlTypeCode)
          Determines whether the native type for the given sql type code (one of the Types constants) has a size specification on this platform.
 boolean isCaseSensitive()
          Determines whether the database has case sensitive identifiers.
 boolean isCommentsSupported()
          Determines whether the database supports comments.
 boolean isEmbeddedForeignKeysNamed()
          Returns whether embedded foreign key constraints should have a name.
 boolean isForeignKeysEmbedded()
          Determines whether foreign key constraints are embedded in the create table clause or as seperate alter table statements.
 boolean isIdentitySpecUsesDefaultValue()
          Determines whether the auto-increment specification uses the DEFAULT value of the column definition.
 boolean isIndicesEmbedded()
          Determines whether the indices are embedded in the create table clause or as seperate statements.
 boolean isPrimaryKeyEmbedded()
          Determines whether primary key constraints are embedded in the create table clause or as seperate alter table statements.
 boolean isRequiringNullAsDefaultValue()
          Determines whether a NULL needs to be explicitly stated when the column has no specified default value.
 boolean isReturningDefaultValueForRequired()
          Determines whether the platform returns synthetic default values (e.g.
 boolean isReturningSystemIndices()
          Determines whether database-generated indices for primary and foreign keys are returned when reading a model from a database.
 boolean isSupportingDefaultValuesForLongTypes()
          Determines whether default values can be specified for LONGVARCHAR/LONGVARBINARY columns.
 boolean isSupportingDelimitedIdentifiers()
          Determines whether delimited identifiers are supported.
 boolean isSupportingNonPKIdentityColumns()
          Determines whether non-primary key columns can be auto-incrementing (IDENTITY columns).
 boolean isSupportingNonUniqueIndices()
          Determines whether non-unique indices are supported.
 boolean isUseAlterTableForDrop()
          Determines whether an ALTER TABLE statement shall be used for dropping indices or constraints.
 boolean isUseDelimitedIdentifiers()
          Determines whether delimited identifiers are used or normal SQL92 identifiers (which may only contain alphanumerical characters and the underscore, must start with a letter and cannot be a reserved keyword).
 void setCanReadAutoIncrementStatus(boolean canReadAutoIncrementStatus)
          Specifies whether the platform is able to read the auto-increment status for columns from an existing database.
 void setCaseSensitive(boolean caseSensitive)
          Specifies whether the database has case sensitive identifiers.
 void setCommentPrefix(String commentPrefix)
          Sets the text that starts a comment.
 void setCommentsSupported(boolean commentsSupported)
          Specifies whether comments are supported by the database.
 void setCommentSuffix(String commentSuffix)
          Sets the text that ends a comment.
 void setDelimiterToken(String delimiterToken)
          Sets the text that is used to delimit identifiers (eg.
 void setEmbeddedForeignKeysNamed(boolean embeddedForeignKeysNamed)
          Specifies whether embedded foreign key constraints should be named.
 void setForeignKeysEmbedded(boolean foreignKeysEmbedded)
          Specifies whether foreign key constraints are embedded in the create table clause or as seperate alter table statements.
 void setHasNullDefault(int sqlTypeCode, boolean hasNullDefault)
          Specifies whether the native type for the given sql type code (one of the Types constants) has a null default value on this platform.
 void setHasPrecisionAndScale(int sqlTypeCode, boolean hasPrecisionAndScale)
          Specifies whether the native type for the given sql type code (one of the Types constants) has precision and scale specifications on this platform.
 void setHasSize(int sqlTypeCode, boolean hasSize)
          Specifies whether the native type for the given sql type code (one of the Types constants) has a size specification on this platform.
 void setIdentitySpecUsesDefaultValue(boolean identitySpecUsesDefaultValue)
          Specifies whether the auto-increment specification uses the DEFAULT value of the column definition.
 void setIndicesEmbedded(boolean indicesEmbedded)
          Specifies whether indices are embedded in the create table clause or as seperate alter table statements.
 void setMaxIdentifierLength(int maxIdentifierLength)
          Sets the maximum length of identifiers that this database allows.
 void setPrimaryKeyEmbedded(boolean primaryKeyEmbedded)
          Specifies whether the primary key constraints are embedded in the create table clause or as seperate alter table statements.
 void setRequiringNullAsDefaultValue(boolean requiresNullAsDefaultValue)
          Specifies whether a NULL needs to be explicitly stated when the column has no specified default value.
 void setReturningDefaultValueForRequired(boolean returningDefaultValue)
          Specifies whether the platform returns synthetic default values (e.g.
 void setReturningSystemIndices(boolean returningSystemIndices)
          Specifies whether database-generated indices for primary and foreign keys are returned when reading a model from a database.
 void setSqlCommandDelimiter(String sqlCommandDelimiter)
          Sets the text separating individual sql commands.
 void setSupportingDefaultValuesForLongTypes(boolean isSupported)
          Specifies whether default values can be specified for LONGVARCHAR/LONGVARBINARY columns.
 void setSupportingDelimitedIdentifiers(boolean areSupported)
          Specifies whether delimited identifiers are supported.
 void setSupportingNonPKIdentityColumns(boolean supportingNonPKIdentityColumns)
          Specifies whether non-primary key columns can be auto-incrementing (IDENTITY columns).
 void setSupportingNonUniqueIndices(boolean supportingNonUniqueIndices)
          Specifies whether non-unique indices are supported.
 void setUseAlterTableForDrop(boolean useAlterTableForDrop)
          Specifies whether an ALTER TABLE statement shall be used for dropping indices or constraints.
 void setUseDelimitedIdentifiers(boolean useDelimitedIdentifiers)
          Determines whether delimited identifiers are used or normal SQL92 identifiers.
 void setValueQuoteToken(String valueQuoteChar)
          Sets the text that is used for for quoting values (e.g.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlatformInfo

public PlatformInfo()
Creates a new platform info object.

Method Detail

isRequiringNullAsDefaultValue

public boolean isRequiringNullAsDefaultValue()
Determines whether a NULL needs to be explicitly stated when the column has no specified default value. Default is false.

Returns:
true if NULL must be written for empty default values

setRequiringNullAsDefaultValue

public void setRequiringNullAsDefaultValue(boolean requiresNullAsDefaultValue)
Specifies whether a NULL needs to be explicitly stated when the column has no specified default value. Default is false.

Parameters:
requiresNullAsDefaultValue - Whether NULL must be written for empty default values

isSupportingDefaultValuesForLongTypes

public boolean isSupportingDefaultValuesForLongTypes()
Determines whether default values can be specified for LONGVARCHAR/LONGVARBINARY columns.

Returns:
true if default values are allowed

setSupportingDefaultValuesForLongTypes

public void setSupportingDefaultValuesForLongTypes(boolean isSupported)
Specifies whether default values can be specified for LONGVARCHAR/LONGVARBINARY columns.

Parameters:
isSupported - true if default values are supported

isPrimaryKeyEmbedded

public boolean isPrimaryKeyEmbedded()
Determines whether primary key constraints are embedded in the create table clause or as seperate alter table statements. The default is embedded pks.

Returns:
true if pk constraints are embedded

setPrimaryKeyEmbedded

public void setPrimaryKeyEmbedded(boolean primaryKeyEmbedded)
Specifies whether the primary key constraints are embedded in the create table clause or as seperate alter table statements.

Parameters:
primaryKeyEmbedded - Whether pk constraints are embedded

isForeignKeysEmbedded

public boolean isForeignKeysEmbedded()
Determines whether foreign key constraints are embedded in the create table clause or as seperate alter table statements. Per default, foreign keys are external.

Returns:
true if fk constraints are embedded

setForeignKeysEmbedded

public void setForeignKeysEmbedded(boolean foreignKeysEmbedded)
Specifies whether foreign key constraints are embedded in the create table clause or as seperate alter table statements.

Parameters:
foreignKeysEmbedded - Whether fk constraints are embedded

isSupportingNonUniqueIndices

public boolean isSupportingNonUniqueIndices()
Determines whether non-unique indices are supported.

Returns:
true if non-unique indices are supported

setSupportingNonUniqueIndices

public void setSupportingNonUniqueIndices(boolean supportingNonUniqueIndices)
Specifies whether non-unique indices are supported.

Parameters:
supportingNonUniqueIndices - true if non-unique indices are supported

isIndicesEmbedded

public boolean isIndicesEmbedded()
Determines whether the indices are embedded in the create table clause or as seperate statements. Per default, indices are external.

Returns:
true if indices are embedded

setIndicesEmbedded

public void setIndicesEmbedded(boolean indicesEmbedded)
Specifies whether indices are embedded in the create table clause or as seperate alter table statements.

Parameters:
indicesEmbedded - Whether indices are embedded

isEmbeddedForeignKeysNamed

public boolean isEmbeddedForeignKeysNamed()
Returns whether embedded foreign key constraints should have a name.

Returns:
true if embedded fks have name

setEmbeddedForeignKeysNamed

public void setEmbeddedForeignKeysNamed(boolean embeddedForeignKeysNamed)
Specifies whether embedded foreign key constraints should be named.

Parameters:
embeddedForeignKeysNamed - Whether embedded fks shall have a name

isSupportingNonPKIdentityColumns

public boolean isSupportingNonPKIdentityColumns()
Determines whether non-primary key columns can be auto-incrementing (IDENTITY columns).

Returns:
true if normal non-PK columns can be auto-incrementing

setSupportingNonPKIdentityColumns

public void setSupportingNonPKIdentityColumns(boolean supportingNonPKIdentityColumns)
Specifies whether non-primary key columns can be auto-incrementing (IDENTITY columns).

Parameters:
supportingNonPKIdentityColumns - true if normal non-PK columns can be auto-incrementing

isIdentitySpecUsesDefaultValue

public boolean isIdentitySpecUsesDefaultValue()
Determines whether the auto-increment specification uses the DEFAULT value of the column definition.

Returns:
true if the auto-increment spec is done via the DEFAULT value

setIdentitySpecUsesDefaultValue

public void setIdentitySpecUsesDefaultValue(boolean identitySpecUsesDefaultValue)
Specifies whether the auto-increment specification uses the DEFAULT value of the column definition.

Parameters:
identitySpecUsesDefaultValue - true if the auto-increment spec is done via the DEFAULT value

isUseAlterTableForDrop

public boolean isUseAlterTableForDrop()
Determines whether an ALTER TABLE statement shall be used for dropping indices or constraints. The default is false.

Returns:
true if ALTER TABLE is required

setUseAlterTableForDrop

public void setUseAlterTableForDrop(boolean useAlterTableForDrop)
Specifies whether an ALTER TABLE statement shall be used for dropping indices or constraints.

Parameters:
useAlterTableForDrop - Whether ALTER TABLE will be used

getMaxIdentifierLength

public int getMaxIdentifierLength()
Returns the maximum length of identifiers that this database allows.

Returns:
The maximum identifier length, -1 if unlimited

setMaxIdentifierLength

public void setMaxIdentifierLength(int maxIdentifierLength)
Sets the maximum length of identifiers that this database allows.

Parameters:
maxIdentifierLength - The maximum identifier length, -1 if unlimited

isCaseSensitive

public boolean isCaseSensitive()
Determines whether the database has case sensitive identifiers.

Returns:
true if case of the the identifiers is important

setCaseSensitive

public void setCaseSensitive(boolean caseSensitive)
Specifies whether the database has case sensitive identifiers.

Parameters:
caseSensitive - true if case of the the identifiers is important

isSupportingDelimitedIdentifiers

public boolean isSupportingDelimitedIdentifiers()
Determines whether delimited identifiers are supported.

Returns:
true if delimited identifiers are supported

setSupportingDelimitedIdentifiers

public void setSupportingDelimitedIdentifiers(boolean areSupported)
Specifies whether delimited identifiers are supported.

Parameters:
areSupported - true if delimited identifiers are supported

isUseDelimitedIdentifiers

public boolean isUseDelimitedIdentifiers()
Determines whether delimited identifiers are used or normal SQL92 identifiers (which may only contain alphanumerical characters and the underscore, must start with a letter and cannot be a reserved keyword). Per default, delimited identifiers are used

Returns:
true if delimited identifiers are used

setUseDelimitedIdentifiers

public void setUseDelimitedIdentifiers(boolean useDelimitedIdentifiers)
Determines whether delimited identifiers are used or normal SQL92 identifiers.

Parameters:
useDelimitedIdentifiers - true if delimited identifiers are used

getDelimiterToken

public String getDelimiterToken()
Returns the text that is used to delimit identifiers (eg. table names). Per default, this is a double quotation character (").

Returns:
The delimiter text

setDelimiterToken

public void setDelimiterToken(String delimiterToken)
Sets the text that is used to delimit identifiers (eg. table names).

Parameters:
delimiterToken - The delimiter text

getValueQuoteToken

public String getValueQuoteToken()
Returns the text that is used for for quoting values (e.g. text) when printing default values and in generates insert/update/delete statements. Per default, this is a single quotation character (').

Returns:
The quote text

setValueQuoteToken

public void setValueQuoteToken(String valueQuoteChar)
Sets the text that is used for for quoting values (e.g. text) when printing default values and in generates insert/update/delete statements.

Parameters:
valueQuoteChar - The new quote text

isCommentsSupported

public boolean isCommentsSupported()
Determines whether the database supports comments.

Returns:
true if comments are supported

setCommentsSupported

public void setCommentsSupported(boolean commentsSupported)
Specifies whether comments are supported by the database.

Parameters:
commentsSupported - true if comments are supported

getCommentPrefix

public String getCommentPrefix()
Returns the string that denotes the beginning of a comment.

Returns:
The comment prefix

setCommentPrefix

public void setCommentPrefix(String commentPrefix)
Sets the text that starts a comment.

Parameters:
commentPrefix - The new comment prefix

getCommentSuffix

public String getCommentSuffix()
Returns the string that denotes the end of a comment. Note that comments will be always on their own line.

Returns:
The comment suffix

setCommentSuffix

public void setCommentSuffix(String commentSuffix)
Sets the text that ends a comment.

Parameters:
commentSuffix - The new comment suffix

getSqlCommandDelimiter

public String getSqlCommandDelimiter()
Returns the text separating individual sql commands.

Returns:
The delimiter text

setSqlCommandDelimiter

public void setSqlCommandDelimiter(String sqlCommandDelimiter)
Sets the text separating individual sql commands.

Parameters:
sqlCommandDelimiter - The delimiter text

addNativeTypeMapping

public void addNativeTypeMapping(int jdbcTypeCode,
                                 String nativeType)
Adds a mapping from jdbc type to database-native type.

Parameters:
jdbcTypeCode - The jdbc type code as defined by Types
nativeType - The native type

addNativeTypeMapping

public void addNativeTypeMapping(int jdbcTypeCode,
                                 String nativeType,
                                 int targetJdbcTypeCode)
Adds a mapping from jdbc type to database-native type.

Parameters:
jdbcTypeCode - The jdbc type code as defined by Types
nativeType - The native type
targetJdbcTypeCode - The jdbc type code corresponding to the native type (e.g. when reading the model from the database)

addNativeTypeMapping

public void addNativeTypeMapping(String jdbcTypeName,
                                 String nativeType)
Adds a mapping from jdbc type to database-native type. Note that this method accesses the named constant in Types via reflection and is thus safe to use under JDK 1.2/1.3 even with constants defined only in later Java versions - for these, the method simply will not add a mapping.

Parameters:
jdbcTypeName - The jdbc type name, one of the constants defined in Types
nativeType - The native type

addNativeTypeMapping

public void addNativeTypeMapping(String jdbcTypeName,
                                 String nativeType,
                                 String targetJdbcTypeName)
Adds a mapping from jdbc type to database-native type. Note that this method accesses the named constant in Types via reflection and is thus safe to use under JDK 1.2/1.3 even with constants defined only in later Java versions - for these, the method simply will not add a mapping.

Parameters:
jdbcTypeName - The jdbc type name, one of the constants defined in Types
nativeType - The native type
targetJdbcTypeName - The jdbc type corresponding to the native type (e.g. when reading the model from the database)

getNativeType

public String getNativeType(int typeCode)
Returns the database-native type for the given type code.

Parameters:
typeCode - The Types type code
Returns:
The native type or null if there isn't one defined

getTargetJdbcType

public int getTargetJdbcType(int typeCode)
Returns the jdbc type corresponding to the native type that is used for the given jdbc type. This is most often the same jdbc type, but can also be a different one. For instance, if a database has no native boolean type, then the source jdbc type would be BIT or BOOLEAN, and the target jdbc type might be TINYINT or SMALLINT.

Parameters:
typeCode - The Types type code
Returns:
The target jdbc type

addDefaultSize

public void addDefaultSize(int jdbcTypeCode,
                           int defaultSize)
Adds a default size for the given jdbc type.

Parameters:
jdbcTypeCode - The jdbc type code
defaultSize - The default size

getDefaultSize

public Integer getDefaultSize(int jdbcTypeCode)
Returns the default size value for the given type, if any.

Parameters:
jdbcTypeCode - The jdbc type code
Returns:
The default size or null if none is defined

addDefaultSize

public void addDefaultSize(String jdbcTypeName,
                           int defaultSize)
Adds a default size for the given jdbc type.

Parameters:
jdbcTypeName - The name of the jdbc type, one of the Types constants
defaultSize - The default size

setHasNullDefault

public void setHasNullDefault(int sqlTypeCode,
                              boolean hasNullDefault)
Specifies whether the native type for the given sql type code (one of the Types constants) has a null default value on this platform.

Parameters:
sqlTypeCode - The sql type code
hasNullDefault - true if the native type has a null default value

hasNullDefault

public boolean hasNullDefault(int sqlTypeCode)
Determines whether the native type for the given sql type code (one of the Types constants) has a null default value on this platform.

Parameters:
sqlTypeCode - The sql type code
Returns:
true if the native type has a null default value

setHasSize

public void setHasSize(int sqlTypeCode,
                       boolean hasSize)
Specifies whether the native type for the given sql type code (one of the Types constants) has a size specification on this platform.

Parameters:
sqlTypeCode - The sql type code
hasSize - true if the native type has a size specification

hasSize

public boolean hasSize(int sqlTypeCode)
Determines whether the native type for the given sql type code (one of the Types constants) has a size specification on this platform.

Parameters:
sqlTypeCode - The sql type code
Returns:
true if the native type has a size specification

setHasPrecisionAndScale

public void setHasPrecisionAndScale(int sqlTypeCode,
                                    boolean hasPrecisionAndScale)
Specifies whether the native type for the given sql type code (one of the Types constants) has precision and scale specifications on this platform.

Parameters:
sqlTypeCode - The sql type code
hasPrecisionAndScale - true if the native type has precision and scale specifications

hasPrecisionAndScale

public boolean hasPrecisionAndScale(int sqlTypeCode)
Determines whether the native type for the given sql type code (one of the Types constants) has precision and scale specifications on this platform.

Parameters:
sqlTypeCode - The sql type code
Returns:
true if the native type has precision and scale specifications

isReturningSystemIndices

public boolean isReturningSystemIndices()
Determines whether database-generated indices for primary and foreign keys are returned when reading a model from a database.

Returns:
true if system indices are read from a live database

setReturningSystemIndices

public void setReturningSystemIndices(boolean returningSystemIndices)
Specifies whether database-generated indices for primary and foreign keys are returned when reading a model from a database.

Parameters:
returningSystemIndices - true if system indices are read from a live database

isReturningDefaultValueForRequired

public boolean isReturningDefaultValueForRequired()
Determines whether the platform returns synthetic default values (e.g. 0 for numeric columns etc.) for non-identity required columns when reading a model from a database.

Returns:
true if synthetic default values are returned for non-identity required columns

setReturningDefaultValueForRequired

public void setReturningDefaultValueForRequired(boolean returningDefaultValue)
Specifies whether the platform returns synthetic default values (e.g. 0 for numeric columns etc.) for non-identity required columns when reading a model from a database.

Parameters:
returningDefaultValue - true if synthetic default values are returned for non-identity required columns

getCanReadAutoIncrementStatus

public boolean getCanReadAutoIncrementStatus()
Determines whether the platform is able to read the auto-increment status for columns from an existing database.

Returns:
true if the auto-increment status can be determined from an existing database

setCanReadAutoIncrementStatus

public void setCanReadAutoIncrementStatus(boolean canReadAutoIncrementStatus)
Specifies whether the platform is able to read the auto-increment status for columns from an existing database.

Parameters:
canReadAutoIncrementStatus - true if the auto-increment status can be determined from an existing database


Copyright © 2005 Apache Software Foundation. All Rights Reserved.