org.apache.torque.engine.platform
Class PlatformDefaultImpl

java.lang.Object
  extended by org.apache.torque.engine.platform.PlatformDefaultImpl
All Implemented Interfaces:
Platform
Direct Known Subclasses:
PlatformMysqlImpl, PlatformOracleImpl

public class PlatformDefaultImpl
extends Object
implements Platform

Default implementation for the Platform interface.

Version:
$Id: PlatformDefaultImpl.java,v 1.1.6.2 2008-04-18 17:04:37 jkeller Exp $
Author:
Martin Poeschl

Field Summary
 
Fields inherited from interface org.apache.torque.engine.platform.Platform
IDENTITY, SEQUENCE
 
Constructor Summary
PlatformDefaultImpl()
          Default constructor.
 
Method Summary
 boolean createNotNullBeforeAutoincrement()
          Returns whether the "not null part" of the definition of a column should be generated before the "autoincrement part" in a "create table" statement.
 String filterInvalidDefaultValues(String defaultValue)
           
 String getAutoIncrement()
           
 Domain getDomainForSchemaType(SchemaType jdbcType)
          Returns the db specific domain for a jdbcType.
 int getMaxColumnNameLength()
          Returns the max column length supported by the db.
 String getNativeIdMethod()
          Returns the native IdMethod (sequence|identity)
 String getNullString(boolean notNull)
           
 List<String> getPrimaryKeys(DatabaseMetaData dbMeta, String dbSchema, String tableName)
          Retrieves a list of the columns composing the primary key for a given table.
 String getSchemaName(String artifactId)
          Given an artifact id, return a string a schema name based on the artifact id that is allowed by the db vendor
 Long getSequenceNextVal(Connection con, String schema, String sequenceName)
           
 String getServerUrl(String url)
          Given a JDBC url return a url that can connect directly to the database server itself.
 List<String> getTableNames(DatabaseMetaData dbMeta, String databaseSchema)
          Get all the table names in the current database that are not system tables.
 String getViewDefinition(Connection con, String schema, String viewName)
           
 boolean hasScale(String sqlType)
          Returns if the RDBMS-specific SQL type has a scale attribute.
 boolean hasSize(String sqlType)
          Returns if the RDBMS-specific SQL type has a size attribute.
 boolean isSpecialDefault(String defaultValue)
           
protected  void setSchemaDomainMapping(Domain domain)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlatformDefaultImpl

public PlatformDefaultImpl()
Default constructor.

Method Detail

setSchemaDomainMapping

protected void setSchemaDomainMapping(Domain domain)

getServerUrl

public String getServerUrl(String url)
Description copied from interface: Platform
Given a JDBC url return a url that can connect directly to the database server itself. ie no database specified

Specified by:
getServerUrl in interface Platform

getSchemaName

public String getSchemaName(String artifactId)
Description copied from interface: Platform
Given an artifact id, return a string a schema name based on the artifact id that is allowed by the db vendor

Specified by:
getSchemaName in interface Platform

getMaxColumnNameLength

public int getMaxColumnNameLength()
Description copied from interface: Platform
Returns the max column length supported by the db.

Specified by:
getMaxColumnNameLength in interface Platform
Returns:
the max column length
See Also:
Platform.getMaxColumnNameLength()

getNativeIdMethod

public String getNativeIdMethod()
Description copied from interface: Platform
Returns the native IdMethod (sequence|identity)

Specified by:
getNativeIdMethod in interface Platform
Returns:
the native IdMethod
See Also:
Platform.getNativeIdMethod()

getDomainForSchemaType

public Domain getDomainForSchemaType(SchemaType jdbcType)
Description copied from interface: Platform
Returns the db specific domain for a jdbcType.

Specified by:
getDomainForSchemaType in interface Platform
Parameters:
jdbcType - the jdbcType name
Returns:
the db specific domain
See Also:
Platform.getDomainForSchemaType(SchemaType)

getNullString

public String getNullString(boolean notNull)
Specified by:
getNullString in interface Platform
Returns:
Only produces a SQL fragment if null values are disallowed.
See Also:
Platform.getNullString(boolean)

getAutoIncrement

public String getAutoIncrement()
Specified by:
getAutoIncrement in interface Platform
Returns:
The RDBMS-specific SQL fragment for autoincrement.
See Also:
Platform.getAutoIncrement()

hasScale

public boolean hasScale(String sqlType)
Description copied from interface: Platform
Returns if the RDBMS-specific SQL type has a scale attribute.

Specified by:
hasScale in interface Platform
Parameters:
sqlType - the SQL type
Returns:
true if the type has a scale attribute
See Also:
TODO collect info for all platforms

hasSize

public boolean hasSize(String sqlType)
Description copied from interface: Platform
Returns if the RDBMS-specific SQL type has a size attribute.

Specified by:
hasSize in interface Platform
Parameters:
sqlType - the SQL type
Returns:
true if the type has a size attribute
See Also:
TODO collect info for all platforms

createNotNullBeforeAutoincrement

public boolean createNotNullBeforeAutoincrement()
Description copied from interface: Platform
Returns whether the "not null part" of the definition of a column should be generated before the "autoincrement part" in a "create table" statement.

Specified by:
createNotNullBeforeAutoincrement in interface Platform
Returns:
true if the "not null part" should be first, false if the "autoincrement part" should be first in a "create table" statement.
See Also:
Platform.createNotNullBeforeAutoincrement()

filterInvalidDefaultValues

public String filterInvalidDefaultValues(String defaultValue)
Specified by:
filterInvalidDefaultValues in interface Platform

isSpecialDefault

public boolean isSpecialDefault(String defaultValue)
Specified by:
isSpecialDefault in interface Platform

getSequenceNextVal

public Long getSequenceNextVal(Connection con,
                               String schema,
                               String sequenceName)
Specified by:
getSequenceNextVal in interface Platform

getViewDefinition

public String getViewDefinition(Connection con,
                                String schema,
                                String viewName)
Specified by:
getViewDefinition in interface Platform

getPrimaryKeys

public List<String> getPrimaryKeys(DatabaseMetaData dbMeta,
                                   String dbSchema,
                                   String tableName)
                            throws SQLException
Retrieves a list of the columns composing the primary key for a given table.

Specified by:
getPrimaryKeys in interface Platform
Parameters:
dbMeta - JDBC metadata.
tableName - Table from which to retrieve PK information.
Returns:
A list of the primary key parts for tableName.
Throws:
SQLException

getTableNames

public List<String> getTableNames(DatabaseMetaData dbMeta,
                                  String databaseSchema)
                           throws SQLException
Get all the table names in the current database that are not system tables.

Specified by:
getTableNames in interface Platform
Parameters:
dbMeta - JDBC database metadata.
Returns:
The list of all the tables in a database.
Throws:
SQLException


Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.