/* ======================================================================
   Parts Copyright 2006 University of Leeds, Oxford University, University of the Highlands and Islands.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

====================================================================== */

package org.bodington.sqldatabase;

import java.lang.reflect.Method;

/**
 * Represents the way fields within an instance of SqlPersistentObejct are
 * stored and retrieved from an SQL database.
 * 
 * @author Jon Maber
 * @version 1
 */

class SqlField extends Object
	{

	/**
	 * Flag indicates that this is a primary key field.
	 */
	static final int PK = 1;

	/**
	 * Flag indicates that this is a foreign key field.
	 */
	static final int FK = 2;

	/**
	 * Which data type does this field belong to.
	 */
	
	int type;

	/**
	 * The column name in the database table for this field.
	 */
	String field;

	/**
	 * The method name for setting this field value.
	 */
	String set_method_name;

	/**
	 * The method name for getting this field value.
	 */
	String get_method_name;

	/**
	 * The name of the class passed to the set method.
	 */
	String set_java_class;

	/**
	 * The name of the class returned from the get method.
	 */
	String get_java_class;

	/**
	 * Indicates whether the field is a primary or foreign key.
	 */
	int flags;

	/**
	 * For foreign keys gives the class type of the foreign object referenced.
	 * (In the future 0 may indicate any subclass of PersistentObject.)
	 */
	
	int foreign_type;

	/**
	 * Name of method to set reference to foreign object.
	 */
	String set_method_name_foreign;

	/**
	 * Name of method to get reference to foreign object.
	 */
	String get_method_name_foreign;

	/**
	 * Actual Method for setting value.
	 */
	
	Method set_method;

	/**
	 * Actual Method for gsetting value.
	 */
	Method get_method;

	/**
	 * Actual Method for setting foreign value.
	 */
	Method set_method_foreign;

	/**
	 * Actual Method for getting foreign value.
	 */
	Method get_method_foreign;

	/**
	 * The SQL data type used in the database for the column named  after field.
	 */
	
	int sql_type;

	/**
	 * The precision of the SQL data type (for variable scale types).
	 */
	
	int sql_precision;
	/**
	 * The scale of the SQL data type (for variable scale types).
	 */
	
	int sql_scale;
	}
