com.j256.ormlite.field.BaseFieldConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ormlite-core Show documentation
Show all versions of ormlite-core Show documentation
Lightweight Object Relational Model (ORM) for persisting objects to SQL databases.
package com.j256.ormlite.field;
import java.sql.SQLException;
import com.j256.ormlite.support.DatabaseResults;
/**
* Base class for field-converters.
*
* @author graywatson
*/
public abstract class BaseFieldConverter implements FieldConverter {
/**
* @throws SQLException
* If there are problems with the conversion.
*/
@Override
public Object javaToSqlArg(FieldType fieldType, Object javaObject) throws SQLException {
// noop pass-thru
return javaObject;
}
@Override
public Object resultToJava(FieldType fieldType, DatabaseResults results, int columnPos) throws SQLException {
Object value = resultToSqlArg(fieldType, results, columnPos);
if (value == null) {
return null;
} else {
return sqlArgToJava(fieldType, value, columnPos);
}
}
/**
* @throws SQLException
* If there are problems with the conversion.
*/
@Override
public Object sqlArgToJava(FieldType fieldType, Object sqlArg, int columnPos) throws SQLException {
// noop pass-thru
return sqlArg;
}
@Override
public boolean isStreamType() {
return false;
}
/**
* @See {@link FieldConverter#makeConfigObject(FieldType)}.
*
* @throws SQLException
* If there are problems creating the config object. Needed for subclasses.
*/
@Override
public Object makeConfigObject(FieldType fieldType) throws SQLException {
return null;
}
}