Class AbstractTypeMapping
- java.lang.Object
- 
- org.eclipse.emf.cdo.server.db.mapping.AbstractTypeMapping
 
- 
- All Implemented Interfaces:
- ITypeMapping
 
 public abstract class AbstractTypeMapping extends java.lang.Object implements ITypeMapping This is a default implementation for theITypeMappinginterface which provides default behavor for all common types. Implementors should provide a constructor which the factory (see below) can use and implementgetResultSetValue(ResultSet). If needed,doSetValue(PreparedStatement, int, Object)can also be overridden as a counterpart togetResultSetValue(ResultSet). Finally, an implementor should also implement a suitable factory for theTypeMappingRegistryand register it either manually usingIManagedContainer.registerFactory(org.eclipse.net4j.util.factory.IFactory)or using the Net4j Extension Pointfactories.- Since:
- 4.0
- Author:
- Eike Stepper, Stefan Winkler
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.eclipse.emf.cdo.server.db.mapping.ITypeMappingITypeMapping.Descriptor, ITypeMapping.Factory, ITypeMapping.Provider, ITypeMapping.Registry
 
- 
 - 
Constructor SummaryConstructors Constructor Description AbstractTypeMapping()Create a new type mapping
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidcreateDBField(org.eclipse.net4j.db.ddl.IDBTable table)Deprecated.voidcreateDBField(org.eclipse.net4j.db.ddl.IDBTable table, java.lang.String fieldName)Creates the DBField and adds it to the given table.protected voiddoSetValue(java.sql.PreparedStatement stmt, int index, java.lang.Object value)Implementors could override this method to convert a given value to the database representation and set it to the prepared statement.protected intgetDBLength(org.eclipse.net4j.db.DBType type)org.eclipse.net4j.db.DBTypegetDBType()protected java.lang.ObjectgetDefaultValue()org.eclipse.emf.ecore.EStructuralFeaturegetFeature()org.eclipse.net4j.db.ddl.IDBFieldgetField()IMappingStrategygetMappingStrategy()protected abstract java.lang.ObjectgetResultSetValue(java.sql.ResultSet resultSet)Subclasses should implement this method to read the value from the result set.protected java.lang.ObjectgetRevisionValue(InternalCDORevision revision)protected intgetSqlType()Returns the SQL type of this TypeMapping.java.lang.ObjectreadValue(java.sql.ResultSet resultSet)Read the value from aResultSetand convert it from the DB to the CDO representation.voidreadValueToRevision(java.sql.ResultSet resultSet, InternalCDORevision revision)Read a value from aResultSet, convert it from the DB to the CDO representation and set it to the feature of the revision.voidsetDBField(org.eclipse.net4j.db.ddl.IDBTable table, java.lang.String fieldName)Sets the DBField.voidsetDBType(org.eclipse.net4j.db.DBType dbType)voidsetDefaultValue(java.sql.PreparedStatement stmt, int index)Set the feature's default value to the JDBCIDBPreparedStatementusing an appropriatesetXxxmethod.voidsetFeature(org.eclipse.emf.ecore.EStructuralFeature feature)voidsetMappingStrategy(IMappingStrategy mappingStrategy)voidsetValue(java.sql.PreparedStatement stmt, int index, java.lang.Object value)Set the given value to the JDBCIDBPreparedStatementusing an appropriatesetXxxmethod.voidsetValueFromRevision(java.sql.PreparedStatement stmt, int index, InternalCDORevision revision)Set a value of the given revision to the JDBCIDBPreparedStatementusing an appropriatesetXxxmethod.java.lang.StringtoString()
 
- 
- 
- 
Method Detail- 
getMappingStrategypublic final IMappingStrategy getMappingStrategy() 
 - 
setMappingStrategypublic final void setMappingStrategy(IMappingStrategy mappingStrategy) - Specified by:
- setMappingStrategyin interface- ITypeMapping
 
 - 
getFeaturepublic final org.eclipse.emf.ecore.EStructuralFeature getFeature() - Specified by:
- getFeaturein interface- ITypeMapping
- Returns:
- The feature which is associated with this mapping.
 
 - 
setFeaturepublic final void setFeature(org.eclipse.emf.ecore.EStructuralFeature feature) - Specified by:
- setFeaturein interface- ITypeMapping
 
 - 
setDBTypepublic final void setDBType(org.eclipse.net4j.db.DBType dbType) - Specified by:
- setDBTypein interface- ITypeMapping
 
 - 
getDBTypepublic org.eclipse.net4j.db.DBType getDBType() - Specified by:
- getDBTypein interface- ITypeMapping
- Returns:
- The db type which is associated with this mapping.
 
 - 
setValueFromRevisionpublic final void setValueFromRevision(java.sql.PreparedStatement stmt, int index, InternalCDORevision revision) throws java.sql.SQLExceptionDescription copied from interface:ITypeMappingSet a value of the given revision to the JDBCIDBPreparedStatementusing an appropriatesetXxxmethod. The feature from which the value is taken is determined byITypeMapping.getFeature().- Specified by:
- setValueFromRevisionin interface- ITypeMapping
- Parameters:
- stmt- the prepared statement to set the value
- index- the index to use for the- setXxxmethod.
- revision- the revision to get the value to set from.
- Throws:
- java.sql.SQLException- if the- setXxxthrows it.
 
 - 
setDefaultValuepublic final void setDefaultValue(java.sql.PreparedStatement stmt, int index) throws java.sql.SQLExceptionDescription copied from interface:ITypeMappingSet the feature's default value to the JDBCIDBPreparedStatementusing an appropriatesetXxxmethod.- Specified by:
- setDefaultValuein interface- ITypeMapping
- Parameters:
- stmt- the prepared statement to set the value
- index- the index to use for the- setXxxmethod.
- Throws:
- java.sql.SQLException- if the- setXxxthrows it.
 
 - 
setValuepublic final void setValue(java.sql.PreparedStatement stmt, int index, java.lang.Object value) throws java.sql.SQLExceptionDescription copied from interface:ITypeMappingSet the given value to the JDBCIDBPreparedStatementusing an appropriatesetXxxmethod.- Specified by:
- setValuein interface- ITypeMapping
- Parameters:
- stmt- the prepared statement to set the value
- index- the index to use for the- setXxxmethod.
- value- the value to set.
- Throws:
- java.sql.SQLException- if the- setXxxthrows it.
 
 - 
createDBField@Deprecated public final void createDBField(org.eclipse.net4j.db.ddl.IDBTable table) Deprecated.- Specified by:
- createDBFieldin interface- ITypeMapping
 
 - 
createDBFieldpublic final void createDBField(org.eclipse.net4j.db.ddl.IDBTable table, java.lang.String fieldName)Description copied from interface:ITypeMappingCreates the DBField and adds it to the given table. The name of the DBField is explicitly determined by the corresponding parameter.- Specified by:
- createDBFieldin interface- ITypeMapping
- Parameters:
- table- the table to add this field to.
- fieldName- the name for the DBField.
 
 - 
getFieldpublic final org.eclipse.net4j.db.ddl.IDBField getField() - Specified by:
- getFieldin interface- ITypeMapping
- Returns:
- The db field which is associated with this mapping.
 
 - 
setDBFieldpublic final void setDBField(org.eclipse.net4j.db.ddl.IDBTable table, java.lang.String fieldName)Description copied from interface:ITypeMappingSets the DBField. The name of the DBField is explicitly determined by the corresponding parameter.- Specified by:
- setDBFieldin interface- ITypeMapping
- Parameters:
- table- the table to add this field to.
- fieldName- the name for the DBField.
 
 - 
readValueToRevisionpublic final void readValueToRevision(java.sql.ResultSet resultSet, InternalCDORevision revision) throws java.sql.SQLExceptionDescription copied from interface:ITypeMappingRead a value from aResultSet, 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 internalITypeMapping.getField()name.- Specified by:
- readValueToRevisionin interface- ITypeMapping
- 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
 
 - 
readValuepublic final java.lang.Object readValue(java.sql.ResultSet resultSet) throws java.sql.SQLExceptionDescription copied from interface:ITypeMappingRead the value from aResultSetand convert it from the DB to the CDO representation. The resultSet field to read from is determined automatically by the internalITypeMapping.getField()name.- Specified by:
- readValuein interface- ITypeMapping
- Parameters:
- resultSet- the result set to read from
- Returns:
- the read value
- Throws:
- java.sql.SQLException- if reading the value throws an SQLException
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
getDefaultValueprotected java.lang.Object getDefaultValue() 
 - 
getRevisionValueprotected final java.lang.Object getRevisionValue(InternalCDORevision revision) 
 - 
doSetValueprotected void doSetValue(java.sql.PreparedStatement stmt, int index, java.lang.Object value) throws java.sql.SQLExceptionImplementors could override this method to convert a given value to the database representation and set it to the prepared statement.- Parameters:
- stmt- the- IDBPreparedStatementwhich 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
- Throws:
- java.sql.SQLException
 
 - 
getSqlTypeprotected int getSqlType() Returns the SQL type of this TypeMapping. The default implementation considers the type map held by themeta-data manager. Subclasses may override.- Returns:
- The sql type of this TypeMapping.
 
 - 
getDBLengthprotected int getDBLength(org.eclipse.net4j.db.DBType type) 
 - 
getResultSetValueprotected abstract java.lang.Object getResultSetValue(java.sql.ResultSet resultSet) throws java.sql.SQLExceptionSubclasses should implement this method to read the value from the result set. Typical implementations should look similar to this one:resultSet.getString(getField().getName())- Parameters:
- resultSet- the result set to read from
- Returns:
- the result value read (this has to be compatible with the feature.
- Throws:
- java.sql.SQLException
 
 
- 
 
-