Package org.firebirdsql.jdbc.metadata

## Class TypeMetadata

- java.lang.Object
- - org.firebirdsql.jdbc.metadata.TypeMetadata

-     public class TypeMetadata
      extends java.lang.Object

  Helper class to determine type metadata conforming to expectations of `DatabaseMetaData`.
  Since:
    4.0
  Author:
    Mark Rotteveel

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `TypeMetadata.Builder` |
    `static class` | `TypeMetadata.TypeBehaviour` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static TypeMetadata.Builder` | `builder​(FirebirdSupportInfo supportInfo)` | Creates type metadata builder.
    `java.lang.Integer` | `getCharOctetLength()` |
    `java.lang.Integer` | `getColumnSize()` | Returns the column size (precision) of the type.
    `static int` | `getDataType​(int sqlType, int sqlSubType, int sqlScale, int characterSetId)` | Derives the JDBC data type from `Types` or `JaybirdTypeCodes` from metadata information.
    `static java.lang.String` | `getDataTypeName​(int sqlType, int sqlSubType, int sqlScale)` | Derives the JDBC/SQL type name from metadata information.
    `int` | `getJdbcType()` |
    `java.lang.Integer` | `getLength()` |
    `int` | `getRadix()` |
    `java.lang.Integer` | `getScale()` | Returns the scale of the field.
    `java.lang.String` | `getSqlTypeName()` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### getJdbcType

          public int getJdbcType()

      Returns:
        The `Types` or `JaybirdTypeCodes` code for this datatype

    - #### getSqlTypeName

          public java.lang.String getSqlTypeName()

      Returns:
        The SQL datatype name, returns `"NULL"` if the type is unknown

    - #### getColumnSize

          public java.lang.Integer getColumnSize()

      Returns the column size (precision) of the type.

      The value returned follows the definition used in `DatabaseMetaData`, as established in `DatabaseMetaData.getColumns(String, String, String, String)` for `COLUMN_SIZE`. The same definition is used for database metadata columns `PRECISION` in, among others, `DatabaseMetaData.getFunctionColumns(String, String, String, String)`.

      This method will also return any non-zero precision information stored for other datatypes than those listed in the `COLUMN_SIZE` definition in the JDBC API.

      Returns:
        The column size as defined in `DatabaseMetaData`, or `null`.

    - #### getLength

          public java.lang.Integer getLength()

      Returns:
        The field length in bytes

    - #### getScale

          public java.lang.Integer getScale()

      Returns the scale of the field.

      For numerical types, returns a zero or positive scale. For types without scale, it returns `null`, for types that have a non-zero scale in the Firebird metadata, it returns the scale as stored.

      Returns:
        The scale of a field, or `null`.

    - #### getRadix

          public int getRadix()

      Returns:
        The radix of numerical precision (either `2` or `10`; returns `10` for non-numerical, non-boolean types.

    - #### getCharOctetLength

          public java.lang.Integer getCharOctetLength()

      Returns:
        The maximum number of bytes for a character type column, `null` otherwise

    - #### builder

          public static TypeMetadata.Builder builder​(FirebirdSupportInfo supportInfo)

      Creates type metadata builder.
      Parameters:
        `supportInfo` - Firebird support info
      Returns:
        Builder for type metadata

    - #### getDataType

          public static int getDataType​(int sqlType,
                                        int sqlSubType,
                                        int sqlScale,
                                        int characterSetId)

      Derives the JDBC data type from `Types` or `JaybirdTypeCodes` from metadata information.
      Parameters:
        `sqlType` - Firebird type code as used in the metadata tables
        `sqlSubType` - Firebird sub-type code as used in the metadata tables
        `sqlScale` - Firebird scale as used in the metadata tables
        `characterSetId` - Character set id as used in the metadata tables
      Returns:
        JDBC data type code.

    - #### getDataTypeName

          public static java.lang.String getDataTypeName​(int sqlType,
                                                         int sqlSubType,
                                                         int sqlScale)

      Derives the JDBC/SQL type name from metadata information.
      Parameters:
        `sqlType` - Firebird type code as used in the metadata tables
        `sqlSubType` - Firebird sub-type code as used in the metadata tables
        `sqlScale` - Firebird scale as used in the metadata tables
      Returns:
        JDBC/SQL type name