|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.emf.cdo.server.db.mapping.AbstractTypeMapping
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
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.eclipse.emf.cdo.server.db.mapping.ITypeMapping |
---|
ITypeMapping.Descriptor, ITypeMapping.Factory, ITypeMapping.Provider, ITypeMapping.Registry |
Constructor Summary | |
---|---|
AbstractTypeMapping()
Create a new type mapping |
Method Summary | |
---|---|
void |
createDBField(IDBTable table)
Creates the DBField and adds it to the given table. |
void |
createDBField(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(DBType type)
|
DBType |
getDBType()
|
protected Object |
getDefaultValue()
|
EStructuralFeature |
getFeature()
|
IDBField |
getField()
|
IMappingStrategy |
getMappingStrategy()
|
protected abstract Object |
getResultSetValue(ResultSet resultSet)
Subclasses should implement this method to read the value from the result set. |
protected Object |
getRevisionValue(InternalCDORevision revision)
|
protected int |
getSqlType()
Returns the SQL type of this TypeMapping. |
Object |
readValue(ResultSet resultSet)
Read the value from a ResultSet and convert it from the DB to the CDO representation. |
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. |
void |
setDBField(IDBTable table,
String fieldName)
Sets the DBField. |
void |
setDBType(DBType dbType)
|
void |
setDefaultValue(PreparedStatement stmt,
int index)
Set the feature's default value to the JDBC PreparedStatement using an appropriate setXxx
method. |
void |
setFeature(EStructuralFeature feature)
|
void |
setMappingStrategy(IMappingStrategy mappingStrategy)
|
void |
setValue(PreparedStatement stmt,
int index,
Object value)
Set the given value to the JDBC PreparedStatement using an appropriate setXxx method. |
void |
setValueFromRevision(PreparedStatement stmt,
int index,
InternalCDORevision revision)
Set a value of the given revision to the JDBC PreparedStatement using an appropriate setXxx
method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AbstractTypeMapping()
Method Detail |
---|
public final void setMappingStrategy(IMappingStrategy mappingStrategy)
setMappingStrategy
in interface ITypeMapping
public final IMappingStrategy getMappingStrategy()
public final void setFeature(EStructuralFeature feature)
setFeature
in interface ITypeMapping
public final EStructuralFeature getFeature()
getFeature
in interface ITypeMapping
public final void setValueFromRevision(PreparedStatement stmt, int index, InternalCDORevision revision) throws SQLException
ITypeMapping
PreparedStatement
using an appropriate setXxx
method. The feature from which the value is taken is determined by ITypeMapping.getFeature()
.
setValueFromRevision
in interface ITypeMapping
stmt
- 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.
SQLException
- if the setXxx
throws it.public final void setDefaultValue(PreparedStatement stmt, int index) throws SQLException
ITypeMapping
PreparedStatement
using an appropriate setXxx
method.
setDefaultValue
in interface ITypeMapping
stmt
- the prepared statement to set the valueindex
- the index to use for the setXxx
method.
SQLException
- if the setXxx
throws it.public final void setValue(PreparedStatement stmt, int index, Object value) throws SQLException
ITypeMapping
PreparedStatement
using an appropriate setXxx
method.
setValue
in interface ITypeMapping
stmt
- the prepared statement to set the valueindex
- the index to use for the setXxx
method.value
- the value to set.
SQLException
- if the setXxx
throws it.public final void createDBField(IDBTable table)
ITypeMapping
createDBField
in interface ITypeMapping
table
- the table to add this field to.public final void createDBField(IDBTable table, String fieldName)
ITypeMapping
createDBField
in interface ITypeMapping
table
- the table to add this field to.fieldName
- the name for the DBField.public final void setDBField(IDBTable table, String fieldName)
ITypeMapping
setDBField
in interface ITypeMapping
table
- the table to add this field to.fieldName
- the name for the DBField.public final IDBField getField()
getField
in interface ITypeMapping
public final void readValueToRevision(ResultSet resultSet, InternalCDORevision revision) throws SQLException
ITypeMapping
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.
readValueToRevision
in interface ITypeMapping
resultSet
- the result set to read fromrevision
- the revision to which the value should be set.
SQLException
- if reading the value throws an SQLExceptionpublic final Object readValue(ResultSet resultSet) throws SQLException
ITypeMapping
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.
readValue
in interface ITypeMapping
resultSet
- the result set to read from
SQLException
- if reading the value throws an SQLExceptionprotected Object getDefaultValue()
protected final Object getRevisionValue(InternalCDORevision revision)
protected void doSetValue(PreparedStatement stmt, int index, Object value) throws SQLException
stmt
- the PreparedStatement
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 DB
SQLException
protected int getSqlType()
meta-data manager
. Subclasses may override.
public final void setDBType(DBType dbType)
setDBType
in interface ITypeMapping
public DBType getDBType()
getDBType
in interface ITypeMapping
protected int getDBLength(DBType type)
protected abstract Object getResultSetValue(ResultSet resultSet) throws SQLException
resultSet.getString(getField().getName())
resultSet
- the result set to read from
feature
.
SQLException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |