/*
 * This class was automatically generated with 
 * <a href="http://www.castor.org">Castor 0.9.7</a>, using an XML
 * Schema.
 * $Id$
 */

package com.queplix.core.jxb.entity.types;

//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/

import java.util.Hashtable;

/**
 * The possible sql types of entity field
 *
 * @version $Revision$ $Date$
 */
public class SqlSType implements java.io.Serializable {

    //--------------------------/
    //- Class/Member Variables -/
    //--------------------------/

    /**
     * The string type
     */
    public static final int STRING_TYPE = 0;

    /**
     * The instance of the string type
     */
    public static final SqlSType STRING = new SqlSType(STRING_TYPE, "string");

    /**
     * The int type
     */
    public static final int INT_TYPE = 1;

    /**
     * The instance of the int type
     */
    public static final SqlSType INT = new SqlSType(INT_TYPE, "int");

    /**
     * The long type
     */
    public static final int LONG_TYPE = 2;

    /**
     * The instance of the long type
     */
    public static final SqlSType LONG = new SqlSType(LONG_TYPE, "long");

    /**
     * The float type
     */
    public static final int FLOAT_TYPE = 3;

    /**
     * The instance of the float type
     */
    public static final SqlSType FLOAT = new SqlSType(FLOAT_TYPE, "float");

    /**
     * The time type
     */
    public static final int TIME_TYPE = 4;

    /**
     * The instance of the time type
     */
    public static final SqlSType TIME = new SqlSType(TIME_TYPE, "time");

    /**
     * The date type
     */
    public static final int DATE_TYPE = 5;

    /**
     * The instance of the date type
     */
    public static final SqlSType DATE = new SqlSType(DATE_TYPE, "date");

    /**
     * The timestamp type
     */
    public static final int TIMESTAMP_TYPE = 6;

    /**
     * The instance of the timestamp type
     */
    public static final SqlSType TIMESTAMP = new SqlSType(TIMESTAMP_TYPE,
            "timestamp");

    /**
     * The memo type
     */
    public static final int MEMO_TYPE = 7;

    /**
     * The instance of the memo type
     */
    public static final SqlSType MEMO = new SqlSType(MEMO_TYPE, "memo");

    /**
     * The binary type
     */
    public static final int BINARY_TYPE = 8;

    /**
     * The instance of the binary type
     */
    public static final SqlSType BINARY = new SqlSType(BINARY_TYPE, "binary");

    /**
     * The memo_long type
     */
    public static final int MEMO_LONG_TYPE = 9;

    /**
     * The instance of the memo_long type
     */
    public static final SqlSType MEMO_LONG = new SqlSType(MEMO_LONG_TYPE,
            "memo_long");

    /**
     * Field _memberTable
     */
    private static java.util.Hashtable _memberTable = init();

    /**
     * Field type
     */
    private int type = -1;

    /**
     * Field stringValue
     */
    private java.lang.String stringValue = null;

    //----------------/
    //- Constructors -/
    //----------------/

    private SqlSType(int type, java.lang.String value) {
        super();
        this.type = type;
        this.stringValue = value;
    } //-- com.queplix.core.jxb.entity.types.SqlSType(int, java.lang.String)

    //-----------/
    //- Methods -/
    //-----------/

    /**
     * Method enumerate
     * <p/>
     * Returns an enumeration of all possible instances of SqlSType
     *
     * @return Enumeration
     */
    public static java.util.Enumeration enumerate() {
        return _memberTable.elements();
    } //-- java.util.Enumeration enumerate() 

    /**
     * Method getType
     * <p/>
     * Returns the type of this SqlSType
     *
     * @return int
     */
    public int getType() {
        return this.type;
    } //-- int getType() 

    /**
     * Method init
     *
     * @return Hashtable
     */
    private static java.util.Hashtable init() {
        Hashtable members = new Hashtable();
        members.put("string", STRING);
        members.put("int", INT);
        members.put("long", LONG);
        members.put("float", FLOAT);
        members.put("time", TIME);
        members.put("date", DATE);
        members.put("timestamp", TIMESTAMP);
        members.put("memo", MEMO);
        members.put("binary", BINARY);
        members.put("memo_long", MEMO_LONG);
        return members;
    } //-- java.util.Hashtable init() 

    /**
     * Method readResolve
     * <p/>
     * will be called during deserialization to replace the
     * deserialized object with the correct constant instance.
     * <br/>
     *
     * @return Object
     */
    private java.lang.Object readResolve() {
        return valueOf(this.stringValue);
    } //-- java.lang.Object readResolve() 

    /**
     * Method toString
     * <p/>
     * Returns the String representation of this SqlSType
     *
     * @return String
     */
    public java.lang.String toString() {
        return this.stringValue;
    } //-- java.lang.String toString() 

    /**
     * Method valueOf
     * <p/>
     * Returns a new SqlSType based on the given String value.
     *
     * @param string
     * @return SqlSType
     */
    public static com.queplix.core.jxb.entity.types.SqlSType valueOf(
            java.lang.String string) {
        java.lang.Object obj = null;
        if(string != null) {
            obj = _memberTable.get(string);
        }
        if(obj == null) {
            String err = "'" + string + "' is not a valid SqlSType";
            throw new IllegalArgumentException(err);
        }
        return (SqlSType) obj;
    } //-- com.queplix.core.jxb.entity.types.SqlSType valueOf(java.lang.String) 

}
