org.eclipse.emf.cdo.server.db.mapping

## Interface ITypeMapping

- All Known Implementing Classes:
    AbstractTypeMapping

      public interface ITypeMapping

  Mapping of single values to and from the database.
  Since:
    2.0
  Author:
    Eike Stepper, Stefan Winkler

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static interface` | `ITypeMapping.Descriptor` A descriptor which describes one type mapping class.
    `static interface` | `ITypeMapping.Factory` A factory for typeMappings.
    `static interface` | `ITypeMapping.Provider` A provider for type mapping information.
    `static interface` | `ITypeMapping.Registry` A global (singleton) registry which collects all available type mappings which are either available in the CDO core, as declared extensions, or registered manually.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `createDBField(IDBTable table)` Deprecated. As of 4.2 use `createDBField(IDBTable, String)`.
    `void` | `createDBField(IDBTable table, java.lang.String fieldName)` Creates the DBField and adds it to the given table.
    `DBType` | `getDBType()`
    `EStructuralFeature` | `getFeature()`
    `IDBField` | `getField()`
    `java.lang.Object` | `readValue(java.sql.ResultSet resultSet)` Read the value from a `ResultSet` and convert it from the DB to the CDO representation.
    `void` | `readValueToRevision(java.sql.ResultSet resultSet, InternalCDORevision revision)` Read a value from a `ResultSet`, convert it from the DB to the CDO representation and set it to the feature of the revision.
    `void` | `setDBField(IDBTable table, java.lang.String fieldName)` Sets the DBField.
    `void` | `setDBType(DBType dbType)`
    `void` | `setDefaultValue(java.sql.PreparedStatement stmt, int index)` Set the feature's default value to the JDBC `IDBPreparedStatement` using an appropriate `setXxx` method.
    `void` | `setFeature(EStructuralFeature feature)`
    `void` | `setMappingStrategy(IMappingStrategy mappingStrategy)`
    `void` | `setValue(java.sql.PreparedStatement stmt, int index, java.lang.Object value)` Set the given value to the JDBC `IDBPreparedStatement` using an appropriate `setXxx` method.
    `void` | `setValueFromRevision(java.sql.PreparedStatement stmt, int index, InternalCDORevision value)` Set a value of the given revision to the JDBC `IDBPreparedStatement` using an appropriate `setXxx` method.

- - ### Method Detail

    - #### getFeature

          EStructuralFeature getFeature()

      Returns:
        The feature which is associated with this mapping.

    - #### getField

          IDBField getField()

      Returns:
        The db field which is associated with this mapping.

    - #### getDBType

          DBType getDBType()

      Returns:
        The db type which is associated with this mapping.
      Since:
        3.0

    - #### setMappingStrategy

          void setMappingStrategy(IMappingStrategy mappingStrategy)

      Since:
        4.0

    - #### setFeature

          void setFeature(EStructuralFeature feature)

      Since:
        4.0

    - #### setDBType

          void setDBType(DBType dbType)

      Since:
        4.0

    - #### createDBField

          @Deprecated
          void createDBField(IDBTable table)

      Deprecated. As of 4.2 use `createDBField(IDBTable, String)`.

    - #### createDBField

          void createDBField(IDBTable table,
                             java.lang.String fieldName)

      Creates the DBField and adds it to the given table. The name of the DBField is explicitly determined by the corresponding parameter.
      Parameters:
        `table` - the table to add this field to.
        `fieldName` - the name for the DBField.

    - #### setDBField

          void setDBField(IDBTable table,
                          java.lang.String fieldName)

      Sets the DBField. The name of the DBField is explicitly determined by the corresponding parameter.
      Parameters:
        `table` - the table to add this field to.
        `fieldName` - the name for the DBField.
      Since:
        3.0

    - #### setValue

          void setValue(java.sql.PreparedStatement stmt,
                        int index,
                        java.lang.Object value)
                 throws java.sql.SQLException

      Set the given value to the JDBC `IDBPreparedStatement` using an appropriate `setXxx` method.
      Parameters:
        `stmt` - the prepared statement to set the value
        `index` - the index to use for the `setXxx` method.
        `value` - the value to set.
      Throws:
        `java.sql.SQLException` - if the `setXxx` throws it.

    - #### setDefaultValue

          void setDefaultValue(java.sql.PreparedStatement stmt,
                               int index)
                        throws java.sql.SQLException

      Set the feature's default value to the JDBC `IDBPreparedStatement` using an appropriate `setXxx` method.
      Parameters:
        `stmt` - the prepared statement to set the value
        `index` - the index to use for the `setXxx` method.
      Throws:
        `java.sql.SQLException` - if the `setXxx` throws it.
      Since:
        3.0

    - #### setValueFromRevision

          void setValueFromRevision(java.sql.PreparedStatement stmt,
                                    int index,
                                    InternalCDORevision value)
                             throws java.sql.SQLException

      Set a value of the given revision to the JDBC `IDBPreparedStatement` using an appropriate `setXxx` method. The feature from which the value is taken is determined by `getFeature()`.
      Parameters:
        `stmt` - the prepared statement to set the value
        `index` - the index to use for the `setXxx` method.
        `value` - the revision to get the value to set from.
      Throws:
        `java.sql.SQLException` - if the `setXxx` throws it.

    - #### readValue

          java.lang.Object readValue(java.sql.ResultSet resultSet)
                              throws java.sql.SQLException

      Read the value from a `ResultSet` and convert it from the DB to the CDO representation. The resultSet field to read from is determined automatically by the internal `getField()` name.
      Parameters:
        `resultSet` - the result set to read from
      Returns:
        the read value
      Throws:
        `java.sql.SQLException` - if reading the value throws an SQLException
      Since:
        3.0

    - #### readValueToRevision

          void readValueToRevision(java.sql.ResultSet resultSet,
                                   InternalCDORevision revision)
                            throws java.sql.SQLException

      Read a value from a `ResultSet`, convert it from the DB to the CDO representation and set it to the feature of the revision. The feature is determined by getFeature() The resultSet field to read from is determined automatically by the internal `getField()` name.
      Parameters:
        `resultSet` - the result set to read from
        `revision` - the revision to which the value should be set.
      Throws:
        `java.sql.SQLException` - if reading the value throws an SQLException
      Since:
        3.0

Copyright (c) 2014 Eike Stepper (Berlin, Germany) and others.
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html