public abstract class AbstractTypeMapping extends java.lang.Object implements ITypeMapping
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.ITypeMapping.Descriptor, ITypeMapping.Factory, ITypeMapping.Provider, ITypeMapping.Registry| Constructor and Description |
|---|
AbstractTypeMapping()
Create a new type mapping
|
| Modifier and Type | Method and Description |
|---|---|
void |
createDBField(IDBTable table)
Deprecated.
|
void |
createDBField(IDBTable table,
java.lang.String fieldName)
Creates the DBField and adds it to the given table.
|
protected void |
doSetValue(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 int |
getDBLength(DBType type) |
DBType |
getDBType() |
protected java.lang.Object |
getDefaultValue() |
EStructuralFeature |
getFeature() |
IDBField |
getField() |
IMappingStrategy |
getMappingStrategy() |
protected abstract java.lang.Object |
getResultSetValue(java.sql.ResultSet resultSet)
Subclasses should implement this method to read the value from the result set.
|
protected java.lang.Object |
getRevisionValue(InternalCDORevision revision) |
protected int |
getSqlType()
Returns the SQL type of this TypeMapping.
|
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 revision)
Set a value of the given revision to the JDBC
IDBPreparedStatement using an appropriate setXxx
method. |
java.lang.String |
toString() |
public final IMappingStrategy getMappingStrategy()
public final void setMappingStrategy(IMappingStrategy mappingStrategy)
setMappingStrategy in interface ITypeMappingpublic final EStructuralFeature getFeature()
getFeature in interface ITypeMappingpublic final void setFeature(EStructuralFeature feature)
setFeature in interface ITypeMappingpublic final void setDBType(DBType dbType)
setDBType in interface ITypeMappingpublic DBType getDBType()
getDBType in interface ITypeMappingpublic final void setValueFromRevision(java.sql.PreparedStatement stmt,
int index,
InternalCDORevision revision)
throws java.sql.SQLException
ITypeMappingIDBPreparedStatement using an appropriate setXxx
method. The feature from which the value is taken is determined by ITypeMapping.getFeature().setValueFromRevision in interface ITypeMappingstmt - the prepared statement to set the valueindex - the index to use for the setXxx method.revision - the revision to get the value to set from.java.sql.SQLException - if the setXxx throws it.public final void setDefaultValue(java.sql.PreparedStatement stmt,
int index)
throws java.sql.SQLException
ITypeMappingIDBPreparedStatement using an appropriate setXxx
method.setDefaultValue in interface ITypeMappingstmt - the prepared statement to set the valueindex - the index to use for the setXxx method.java.sql.SQLException - if the setXxx throws it.public final void setValue(java.sql.PreparedStatement stmt,
int index,
java.lang.Object value)
throws java.sql.SQLException
ITypeMappingIDBPreparedStatement using an appropriate setXxx method.setValue in interface ITypeMappingstmt - the prepared statement to set the valueindex - the index to use for the setXxx method.value - the value to set.java.sql.SQLException - if the setXxx throws it.@Deprecated public final void createDBField(IDBTable table)
createDBField in interface ITypeMappingpublic final void createDBField(IDBTable table, java.lang.String fieldName)
ITypeMappingcreateDBField in interface ITypeMappingtable - the table to add this field to.fieldName - the name for the DBField.public final IDBField getField()
getField in interface ITypeMappingpublic final void setDBField(IDBTable table, java.lang.String fieldName)
ITypeMappingsetDBField in interface ITypeMappingtable - the table to add this field to.fieldName - the name for the DBField.public final void readValueToRevision(java.sql.ResultSet resultSet,
InternalCDORevision revision)
throws java.sql.SQLException
ITypeMappingResultSet, 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.readValueToRevision in interface ITypeMappingresultSet - the result set to read fromrevision - the revision to which the value should be set.java.sql.SQLException - if reading the value throws an SQLExceptionpublic final java.lang.Object readValue(java.sql.ResultSet resultSet)
throws java.sql.SQLException
ITypeMappingResultSet 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.readValue in interface ITypeMappingresultSet - the result set to read fromjava.sql.SQLException - if reading the value throws an SQLExceptionpublic java.lang.String toString()
toString in class java.lang.Objectprotected java.lang.Object getDefaultValue()
protected final java.lang.Object getRevisionValue(InternalCDORevision revision)
protected void doSetValue(java.sql.PreparedStatement stmt,
int index,
java.lang.Object value)
throws java.sql.SQLException
stmt - the IDBPreparedStatement which is used for DB accessindex - the parameter index in the statement which should be setvalue - the value of the feature which should be written into the DBjava.sql.SQLExceptionprotected int getSqlType()
meta-data manager. Subclasses may override.protected int getDBLength(DBType type)
protected abstract java.lang.Object getResultSetValue(java.sql.ResultSet resultSet)
throws java.sql.SQLException
resultSet.getString(getField().getName())resultSet - the result set to read fromfeature.java.sql.SQLExceptionCopyright (c) 2004-2019 Eike Stepper (Loehne, 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