package org.seamframework.sql;

import java.math.BigDecimal;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;

public class Type<X> {
	
	private final int jdbcType;
	private final Class<X> javaType;
	
	public Type(Class<X> javaType, int jdbcType) {
		this.jdbcType = jdbcType;
		this.javaType = javaType;
	}
	
	public int getJdbcType() {
		return jdbcType;
	}

	public Class<X> getJavaType() {
		return javaType;
	}

	/**
	 * <P>The constant in the Java programming language, sometimes referred
	 * to as a type code, that identifies the generic SQL type 
	 * <code>BIT</code>.
	 */
		public final static Type<Boolean> BIT = new Type<Boolean>(Boolean.class, -7);

	/**
	 * <P>The constant in the Java programming language, sometimes referred
	 * to as a type code, that identifies the generic SQL type 
	 * <code>TINYINT</code>.
	 */
		public final static Type<Byte> TINYINT = new Type<Byte>(Byte.class, -6);

	/**
	 * <P>The constant in the Java programming language, sometimes referred
	 * to as a type code, that identifies the generic SQL type 
	 * <code>SMALLINT</code>.
	 */
		public final static Type<Short> SMALLINT = new Type<Short>(Short.class, 5);

	/**
	 * <P>The constant in the Java programming language, sometimes referred
	 * to as a type code, that identifies the generic SQL type 
	 * <code>INTEGER</code>.
	 */
		public final static Type<Integer> INTEGER = new Type<Integer>(Integer.class, 4);

	/**
	 * <P>The constant in the Java programming language, sometimes referred
	 * to as a type code, that identifies the generic SQL type 
	 * <code>BIGINT</code>.
	 */
		public final static Type<Long> BIGINT = new Type<Long>(Long.class, -5);

	/**
	 * <P>The constant in the Java programming language, sometimes referred
	 * to as a type code, that identifies the generic SQL type 
	 * <code>FLOAT</code>.
	 */
		public final static Type<Double> FLOAT = new Type<Double>(Double.class, 6);

	/**
	 * <P>The constant in the Java programming language, sometimes referred
	 * to as a type code, that identifies the generic SQL type 
	 * <code>REAL</code>.
	 */
		public final static Type<Float> REAL = new Type<Float>(Float.class, 7);


	/**
	 * <P>The constant in the Java programming language, sometimes referred
	 * to as a type code, that identifies the generic SQL type 
	 * <code>DOUBLE</code>.
	 */
		public final static Type<Double> DOUBLE = new Type<Double>(Double.class, 8);

	/**
	 * <P>The constant in the Java programming language, sometimes referred
	 * to as a type code, that identifies the generic SQL type 
	 * <code>NUMERIC</code>.
	 */
		public final static Type<BigDecimal> NUMERIC = new Type<BigDecimal>(BigDecimal.class, 2);

	/**
	 * <P>The constant in the Java programming language, sometimes referred
	 * to as a type code, that identifies the generic SQL type 
	 * <code>DECIMAL</code>.
	 */
		public final static Type<BigDecimal> DECIMAL = new Type<BigDecimal>(BigDecimal.class, 3);

	/**
	 * <P>The constant in the Java programming language, sometimes referred
	 * to as a type code, that identifies the generic SQL type 
	 * <code>CHAR</code>.
	 */
		public final static Type<String> CHAR = new Type<String>(String.class, 1);

	/**
	 * <P>The constant in the Java programming language, sometimes referred
	 * to as a type code, that identifies the generic SQL type 
	 * <code>VARCHAR</code>.
	 */
		public final static Type<String> VARCHAR = new Type<String>(String.class, 12);

	/**
	 * <P>The constant in the Java programming language, sometimes referred
	 * to as a type code, that identifies the generic SQL type 
	 * <code>LONGVARCHAR</code>.
	 */
		public final static Type<String> LONGVARCHAR = new Type<String>(String.class, -1);


	/**
	 * <P>The constant in the Java programming language, sometimes referred
	 * to as a type code, that identifies the generic SQL type 
	 * <code>DATE</code>.
	 */
		public final static Type<Date> DATE = new Type<Date>(Date.class, 91);

	/**
	 * <P>The constant in the Java programming language, sometimes referred
	 * to as a type code, that identifies the generic SQL type 
	 * <code>TIME</code>.
	 */
		public final static Type<Time> TIME = new Type<Time>(Time.class, 92);

	/**
	 * <P>The constant in the Java programming language, sometimes referred
	 * to as a type code, that identifies the generic SQL type 
	 * <code>TIMESTAMP</code>.
	 */
		public final static Type<Timestamp> TIMESTAMP = new Type<Timestamp>(Timestamp.class, 93);


	/**
	 * <P>The constant in the Java programming language, sometimes referred
	 * to as a type code, that identifies the generic SQL type 
	 * <code>BINARY</code>.
	 */
		public final static Type<byte[]> BINARY = new Type<byte[]>(byte[].class, -2);

	/**
	 * <P>The constant in the Java programming language, sometimes referred
	 * to as a type code, that identifies the generic SQL type 
	 * <code>VARBINARY</code>.
	 */
		public final static Type<byte[]> VARBINARY = new Type<byte[]>(byte[].class, -3);

	/**
	 * <P>The constant in the Java programming language, sometimes referred
	 * to as a type code, that identifies the generic SQL type 
	 * <code>LONGVARBINARY</code>.
	 */
		public final static Type<byte[]> LONGVARBINARY = new Type<byte[]>(byte[].class, -4);

//	/**
//	 * <P>The constant in the Java programming language
//	 * that identifies the generic SQL value 
//	 * <code>NULL</code>.
//	 */
//		public final static Type<X> NULL		=   0;

	    /**
	     * The constant in the Java programming language that indicates
	     * that the SQL type is database-specific and
	     * gets mapped to a Java object that can be accessed via
	     * the methods <code>getObject</code> and <code>setObject</code>.
	     */
		public final static Type<Object> OTHER = new Type<Object>(Object.class, 1111);

	        

	    /**
	     * The constant in the Java programming language, sometimes referred to
	     * as a type code, that identifies the generic SQL type
	     * <code>JAVA_OBJECT</code>.
	     * @since 1.2
	     */
		public final static Type<Object> JAVA_OBJECT = new Type<Object>(Object.class, 2000);

//	    /**
//	     * The constant in the Java programming language, sometimes referred to
//	     * as a type code, that identifies the generic SQL type
//	     * <code>DISTINCT</code>.
//	     * @since 1.2
//	     */
//	        public final static Type<X> DISTINCT            = 2001;
//		
//	    /**
//	     * The constant in the Java programming language, sometimes referred to
//	     * as a type code, that identifies the generic SQL type
//	     * <code>STRUCT</code>.
//	     * @since 1.2
//	     */
//	        public final static Type<X> STRUCT              = 2002;
//
//	    /**
//	     * The constant in the Java programming language, sometimes referred to
//	     * as a type code, that identifies the generic SQL type
//	     * <code>ARRAY</code>.
//	     * @since 1.2
//	     */
//	        public final static Type<X> ARRAY               = 2003;

	    /**
	     * The constant in the Java programming language, sometimes referred to
	     * as a type code, that identifies the generic SQL type
	     * <code>BLOB</code>.
	     * @since 1.2
	     */
	        public final static Type<Blob> BLOB  = new Type<Blob>(Blob.class, 2004);

	    /**
	     * The constant in the Java programming language, sometimes referred to
	     * as a type code, that identifies the generic SQL type
	     * <code>CLOB</code>.
	     * @since 1.2
	     */
	        public final static Type<Clob> CLOB  = new Type<Clob>(Clob.class, 2005);
//
//	    /**
//	     * The constant in the Java programming language, sometimes referred to
//	     * as a type code, that identifies the generic SQL type
//	     * <code>REF</code>.
//	     * @since 1.2
//	     */
//	        public final static Type<X> REF                 = 2006;
//	        
//	    /**
//	     * The constant in the Java programming language, somtimes referred to
//	     * as a type code, that identifies the generic SQL type <code>DATALINK</code>.
//	     *
//	     * @since 1.4
//	     */
//	    public final static Type<X> DATALINK = 70;
//
//	    /**
//	     * The constant in the Java programming language, somtimes referred to
//	     * as a type code, that identifies the generic SQL type <code>BOOLEAN</code>.
//	     *
//	     * @since 1.4
//	     */
//	    public final static Type<X> BOOLEAN = 16;
//	    
//	    //------------------------- JDBC 4.0 -----------------------------------
//	    
//	    /**
//	     * The constant in the Java programming language, sometimes referred to
//	     * as a type code, that identifies the generic SQL type <code>ROWID</code>
//	     * 
//	     * @since 1.6
//	     *
//	     */
//	    public final static Type<X> ROWID = -8;
//
//	    /**
//	     * The constant in the Java programming language, sometimes referred to
//	     * as a type code, that identifies the generic SQL type <code>NCHAR</code>
//	     *
//	     * @since 1.6
//	     */
//	    public static final Type<X> NCHAR = -15;
//
//	    /**
//	     * The constant in the Java programming language, sometimes referred to
//	     * as a type code, that identifies the generic SQL type <code>NVARCHAR</code>.
//	     *
//	     * @since 1.6
//	     */
//	    public static final Type<X> NVARCHAR = -9;
//
//	    /**
//	     * The constant in the Java programming language, sometimes referred to
//	     * as a type code, that identifies the generic SQL type <code>LONGNVARCHAR</code>.
//	     *
//	     * @since 1.6
//	     */
//	    public static final Type<X> LONGNVARCHAR = -16;
//
//	    /**
//	     * The constant in the Java programming language, sometimes referred to
//	     * as a type code, that identifies the generic SQL type <code>NCLOB</code>.
//	     *
//	     * @since 1.6
//	     */
//	    public static final Type<X> NCLOB = 2011;
//
//	    /**
//	     * The constant in the Java programming language, sometimes referred to
//	     * as a type code, that identifies the generic SQL type <code>XML</code>.
//	     *
//	     * @since 1.6 
//	     */
//	    public static final Type<X> SQLXML = 2009;

}
