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

# Klasse AbstractTypeMapping

java.lang.Object
org.eclipse.emf.cdo.server.db.mapping.AbstractTypeMapping

Alle implementierten Schnittstellen:
  `ITypeMapping`

public abstract class AbstractTypeMapping extends Object implements ITypeMapping
This is a default implementation for the `ITypeMapping` interface which provides default behavor for all common types. Implementors should provide a constructor which the factory (see below) can use and implement `getResultSetValue(ResultSet)`. If needed, `doSetValue(PreparedStatement, int, Object)` can also be overridden as a counterpart to `getResultSetValue(ResultSet)`. Finally, an implementor should also implement a suitable factory for the `TypeMappingRegistry` and register it either manually using `IManagedContainer.registerFactory(org.eclipse.net4j.util.factory.IFactory)` or using the Net4j Extension Point `factories`.

Seit:
  4.0
Autor:
  Eike Stepper, Stefan Winkler

## Verschachtelte Klassen - Übersicht

## Von Schnittstelle geerbte verschachtelte Klassen/Schnittstellen org.eclipse.emf.cdo.server.db.mapping.ITypeMapping

`ITypeMapping.Descriptor, ITypeMapping.Factory, ITypeMapping.Provider, ITypeMapping.Registry`

## Konstruktorübersicht

Konstruktoren
Konstruktor
Beschreibung
`AbstractTypeMapping()`
Create a new type mapping

## Methodenübersicht

Modifizierer und Typ
Methode
Beschreibung
`final void`
`createDBField(org.eclipse.net4j.db.ddl.IDBTable table)`
Veraltet.
`final void`
`createDBField(org.eclipse.net4j.db.ddl.IDBTable table, String fieldName)`
Creates the DBField and adds it to the given table.
`protected void`
`doSetValue(PreparedStatement stmt, int index, Object value)`
Implementors could override this method to convert a given value to the database representation and set it to the prepared statement.
`protected int`
`getDBLength(org.eclipse.net4j.db.DBType type)`
`org.eclipse.net4j.db.DBType`
`getDBType()`
`protected Object`
`getDefaultValue()`
`final EStructuralFeature`
`getFeature()`
`final org.eclipse.net4j.db.ddl.IDBField`
`getField()`
`final IMappingStrategy`
`getMappingStrategy()`
`protected abstract Object`
`getResultSetValue(ResultSet resultSet)`
Subclasses should implement this method to read the value from the result set.
`protected final Object`
`getRevisionValue(InternalCDORevision revision)`
`protected int`
`getSqlType()`
Returns the SQL type of this TypeMapping.
`final Object`
`readValue(ResultSet resultSet)`
Read the value from a `ResultSet` and convert it from the DB to the CDO representation.
`final void`
`readValueToRevision(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.
`final void`
`setDBField(org.eclipse.net4j.db.ddl.IDBTable table, String fieldName)`
Sets the DBField.
`final void`
`setDBType(org.eclipse.net4j.db.DBType dbType)`
`final void`
`setDefaultValue(PreparedStatement stmt, int index)`
Set the feature's default value to the JDBC `IDBPreparedStatement` using an appropriate `setXxx` method.
`final void`
`setFeature(EStructuralFeature feature)`
`final void`
`setMappingStrategy(IMappingStrategy mappingStrategy)`
`final void`
`setValue(PreparedStatement stmt, int index, Object value)`
Set the given value to the JDBC `IDBPreparedStatement` using an appropriate `setXxx` method.
`final void`
`setValueFromRevision(PreparedStatement stmt, int index, InternalCDORevision revision)`
Set a value of the given revision to the JDBC `IDBPreparedStatement` using an appropriate `setXxx` method.
`String`
`toString()`

### Von Klasse geerbte Methoden java.lang.Object

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

## Konstruktordetails

### AbstractTypeMapping

public AbstractTypeMapping()
Create a new type mapping

## Methodendetails

### getMappingStrategy

public final IMappingStrategy getMappingStrategy()

### setMappingStrategy

public final void setMappingStrategy(IMappingStrategy mappingStrategy)

Angegeben von:
  `setMappingStrategy` in Schnittstelle `ITypeMapping`

### getFeature

public final EStructuralFeature getFeature()

Angegeben von:
  `getFeature` in Schnittstelle `ITypeMapping`
Gibt zurück:
  The feature which is associated with this mapping.

### setFeature

public final void setFeature(EStructuralFeature feature)

Angegeben von:
  `setFeature` in Schnittstelle `ITypeMapping`

### setDBType

public final void setDBType(org.eclipse.net4j.db.DBType dbType)

Angegeben von:
  `setDBType` in Schnittstelle `ITypeMapping`

### getDBType

public org.eclipse.net4j.db.DBType getDBType()

Angegeben von:
  `getDBType` in Schnittstelle `ITypeMapping`
Gibt zurück:
  The db type which is associated with this mapping.

### setValueFromRevision

public final void setValueFromRevision(PreparedStatement stmt, int index, InternalCDORevision revision) throws SQLException
Beschreibung aus Schnittstelle kopiert: `ITypeMapping`
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 `ITypeMapping.getFeature()`.

Angegeben von:
  `setValueFromRevision` in Schnittstelle `ITypeMapping`
Parameter:
  `stmt` - the prepared statement to set the value
  `index` - the index to use for the `setXxx` method.
  `revision` - the revision to get the value to set from.
Löst aus:
  `SQLException` - if the `setXxx` throws it.

### setDefaultValue

public final void setDefaultValue(PreparedStatement stmt, int index) throws SQLException
Beschreibung aus Schnittstelle kopiert: `ITypeMapping`
Set the feature's default value to the JDBC `IDBPreparedStatement` using an appropriate `setXxx` method.

Angegeben von:
  `setDefaultValue` in Schnittstelle `ITypeMapping`
Parameter:
  `stmt` - the prepared statement to set the value
  `index` - the index to use for the `setXxx` method.
Löst aus:
  `SQLException` - if the `setXxx` throws it.

### setValue

public final void setValue(PreparedStatement stmt, int index, Object value) throws SQLException
Beschreibung aus Schnittstelle kopiert: `ITypeMapping`
Set the given value to the JDBC `IDBPreparedStatement` using an appropriate `setXxx` method.

Angegeben von:
  `setValue` in Schnittstelle `ITypeMapping`
Parameter:
  `stmt` - the prepared statement to set the value
  `index` - the index to use for the `setXxx` method.
  `value` - the value to set.
Löst aus:
  `SQLException` - if the `setXxx` throws it.

### createDBField

@Deprecated public final void createDBField(org.eclipse.net4j.db.ddl.IDBTable table)
Veraltet.

Angegeben von:
  `createDBField` in Schnittstelle `ITypeMapping`

### createDBField

public final void createDBField(org.eclipse.net4j.db.ddl.IDBTable table, String fieldName)
Beschreibung aus Schnittstelle kopiert: `ITypeMapping`
Creates the DBField and adds it to the given table. The name of the DBField is explicitly determined by the corresponding parameter.

Angegeben von:
  `createDBField` in Schnittstelle `ITypeMapping`
Parameter:
  `table` - the table to add this field to.
  `fieldName` - the name for the DBField.

### getField

public final org.eclipse.net4j.db.ddl.IDBField getField()

Angegeben von:
  `getField` in Schnittstelle `ITypeMapping`
Gibt zurück:
  The db field which is associated with this mapping.

### setDBField

public final void setDBField(org.eclipse.net4j.db.ddl.IDBTable table, String fieldName)
Beschreibung aus Schnittstelle kopiert: `ITypeMapping`
Sets the DBField. The name of the DBField is explicitly determined by the corresponding parameter.

Angegeben von:
  `setDBField` in Schnittstelle `ITypeMapping`
Parameter:
  `table` - the table to add this field to.
  `fieldName` - the name for the DBField.

### readValueToRevision

public final void readValueToRevision(ResultSet resultSet, InternalCDORevision revision) throws SQLException
Beschreibung aus Schnittstelle kopiert: `ITypeMapping`
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 `ITypeMapping.getField()` name.

Angegeben von:
  `readValueToRevision` in Schnittstelle `ITypeMapping`
Parameter:
  `resultSet` - the result set to read from
  `revision` - the revision to which the value should be set.
Löst aus:
  `SQLException` - if reading the value throws an SQLException

### readValue

public final Object readValue(ResultSet resultSet) throws SQLException
Beschreibung aus Schnittstelle kopiert: `ITypeMapping`
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 `ITypeMapping.getField()` name.

Angegeben von:
  `readValue` in Schnittstelle `ITypeMapping`
Parameter:
  `resultSet` - the result set to read from
Gibt zurück:
  the read value
Löst aus:
  `SQLException` - if reading the value throws an SQLException

### toString

public String toString()

Setzt außer Kraft:
  `toString` in Klasse `Object`

### getDefaultValue

protected Object getDefaultValue()

### getRevisionValue

protected final Object getRevisionValue(InternalCDORevision revision)

### doSetValue

protected void doSetValue(PreparedStatement stmt, int index, Object value) throws SQLException
Implementors could override this method to convert a given value to the database representation and set it to the prepared statement.

Parameter:
  `stmt` - the `IDBPreparedStatement` which is used for DB access
  `index` - the parameter index in the statement which should be set
  `value` - the value of the feature which should be written into the DB
Löst aus:
  `SQLException`

### getSqlType

protected int getSqlType()
Returns the SQL type of this TypeMapping. The default implementation considers the type map held by the `meta-data manager`. Subclasses may override.

Gibt zurück:
  The sql type of this TypeMapping.

### getDBLength

protected int getDBLength(org.eclipse.net4j.db.DBType type)

### getResultSetValue

protected abstract Object getResultSetValue(ResultSet resultSet) throws SQLException
Subclasses should implement this method to read the value from the result set. Typical implementations should look similar to this one: `resultSet.getString(getField().getName())`

Parameter:
  `resultSet` - the result set to read from
Gibt zurück:
  the result value read (this has to be compatible with the `feature`.
Löst aus:
  `SQLException`