org.apache.torque.templates.platform

## Class PlatformDefaultImpl

- java.lang.Object
- - org.apache.torque.templates.platform.PlatformDefaultImpl

- All Implemented Interfaces:
    Platform
  Direct Known Subclasses:
    PlatformDerbyImpl, PlatformHsqldbImpl, PlatformMssqlImpl, PlatformMysqlImpl, PlatformOracleImpl, PlatformPostgresqlImpl

      public class PlatformDefaultImpl
      extends Object
      implements Platform

  Default implementation for the Platform interface.
  Version:
    $Id: PlatformDefaultImpl.java 1872379 2020-01-06 13:45:27Z tv $
  Author:
    Martin Poeschl

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PlatformDefaultImpl()` Default constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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.
    `protected boolean` | `escapeBackslashes()` Returns whether backslashes must be escaped in string literals.
    `protected String` | `formatDateTimeString(Date date, String format)` Helper function to format date values to a platform-specific string
    `String` | `getAutoIncrement()`
    `String` | `getDateString(Date date)` Formats the given date as date string which is parseable by the database.
    `String` | `getNullString(boolean notNull)`
    `String` | `getSizeSuffix(String sqlType)` Returns a possible SQL suffix for column definitions of certain SQL Types, e.g.
    `SqlType` | `getSqlTypeForSchemaType(SchemaType schemaType)` Returns the db specific SQL type for a Torque type.
    `String` | `getTimestampString(Date date)` Formats the given date as timestamp string which is parseable by the database.
    `String` | `getTimeString(Date date)` Formats the given date as time string which is parseable by the database.
    `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` | `hasUniqueConstraintSize()` Returns whether the database has schema support unique constraint for columns with size
    `String` | `quoteAndEscape(String text)` Quotes and escapes a string such that it can be used as literal String value in SQL.
    `protected void` | `setSchemaTypeToSqlTypeMapping(SchemaType schemaType, SqlType sqlType)` Adds a mapping to the torque schema type -> sql type map.
    `boolean` | `usesStandaloneSchema()` Returns whether the database has schema support where a schema is not tied to a user (oracle) or database (mysql), but can be created separately.

    - ### 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

    - #### setSchemaTypeToSqlTypeMapping

          protected void setSchemaTypeToSqlTypeMapping(SchemaType schemaType,
                                                       SqlType sqlType)

      Adds a mapping to the torque schema type -> sql type map.
      Parameters:
        `schemaType` - the torque schema type which should be mapped, not null.
        `sqlType` - the sql type for the torque schema type, not null.

    - #### formatDateTimeString

          protected String formatDateTimeString(Date date,
                                                String format)

      Helper function to format date values to a platform-specific string
      Parameters:
        `date` - the Date object
        `format` - the format string
      Returns:
        the formatted string

    - #### getSqlTypeForSchemaType

          public SqlType getSqlTypeForSchemaType(SchemaType schemaType)

      Description copied from interface: `Platform`
      Returns the db specific SQL type for a Torque type.
      Specified by:
        `getSqlTypeForSchemaType` in interface `Platform`
      Parameters:
        `schemaType` - the Torque type, not null.
      Returns:
        the db specific SQL type, or null if no SQL type is defined for the given Torque type.
      See Also:
        `Platform.getSqlTypeForSchemaType(SchemaType)`

    - #### getNullString

          public String getNullString(boolean notNull)

      Specified by:
        `getNullString` in interface `Platform`
      Parameters:
        `notNull` - flag for not null
      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`

    - #### getSizeSuffix

          public String getSizeSuffix(String sqlType)

      Returns a possible SQL suffix for column definitions of certain SQL Types, e.g. for Oracle VARCHAR2 columns, it typically makes sense to use 'x CHAR' instead of 'x' as size.
      Specified by:
        `getSizeSuffix` in interface `Platform`
      Parameters:
        `sqlType` - the SQL type to determine the suffix for.
      Returns:
        The size suffix, not null. This implementation always returns the empty string.

    - #### 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()`

    - #### quoteAndEscape

          public String quoteAndEscape(String text)

      Description copied from interface: `Platform`
      Quotes and escapes a string such that it can be used as literal String value in SQL.
      Specified by:
        `quoteAndEscape` in interface `Platform`
      Parameters:
        `text` - The string to escape, or null.
      Returns:
        the escaped String, not null.
      See Also:
        `Platform.quoteAndEscape(String)`

    - #### escapeBackslashes

          protected boolean escapeBackslashes()

      Returns whether backslashes must be escaped in string literals.
      Returns:
        true if backslashes bust be escaped, false otherwise.

    - #### getDateString

          public String getDateString(Date date)

      Formats the given date as date string which is parseable by the database.
      Specified by:
        `getDateString` in interface `Platform`
      Parameters:
        `date` - the date to format.
      Returns:
        the date string, inclusive string escaping.

    - #### getTimeString

          public String getTimeString(Date date)

      Formats the given date as time string which is parseable by the database.
      Specified by:
        `getTimeString` in interface `Platform`
      Parameters:
        `date` - the date to format.
      Returns:
        the time string, inclusive string escaping.

    - #### getTimestampString

          public String getTimestampString(Date date)

      Formats the given date as timestamp string which is parseable by the database.
      Specified by:
        `getTimestampString` in interface `Platform`
      Parameters:
        `date` - the date to format.
      Returns:
        the timestamp string, inclusive string escaping.

    - #### usesStandaloneSchema

          public boolean usesStandaloneSchema()

      Returns whether the database has schema support where a schema is not tied to a user (oracle) or database (mysql), but can be created separately.
      Specified by:
        `usesStandaloneSchema` in interface `Platform`
      Returns:
        this implementation returns false.

    - #### hasUniqueConstraintSize

          public boolean hasUniqueConstraintSize()

      Description copied from interface: `Platform`
      Returns whether the database has schema support unique constraint for columns with size
      Specified by:
        `hasUniqueConstraintSize` in interface `Platform`
      Returns:
        true if unique column constraint has size

Copyright © 2000–2020 The Apache Software Foundation. All rights reserved.