All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.j256.ormlite.field.BaseFieldConverter Maven / Gradle / Ivy

Go to download

Lightweight Object Relational Model (ORM) for persisting objects to SQL databases.

There is a newer version: 6.1
Show newest version
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;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy