/*
 * 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 reference types
 *
 * @version $Revision$ $Date$
 */
public class RefSType implements java.io.Serializable {

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

    /**
     * The 1:1 type
     */
    public static final int VALUE_0_TYPE = 0;

    /**
     * The instance of the 1:1 type
     */
    public static final RefSType VALUE_0 = new RefSType(VALUE_0_TYPE, "1:1");

    /**
     * The 1:n type
     */
    public static final int VALUE_1_TYPE = 1;

    /**
     * The instance of the 1:n type
     */
    public static final RefSType VALUE_1 = new RefSType(VALUE_1_TYPE, "1:n");

    /**
     * The n:1 type
     */
    public static final int VALUE_2_TYPE = 2;

    /**
     * The instance of the n:1 type
     */
    public static final RefSType VALUE_2 = new RefSType(VALUE_2_TYPE, "n:1");

    /**
     * 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 RefSType(int type, java.lang.String value) {
        super();
        this.type = type;
        this.stringValue = value;
    } //-- com.queplix.core.jxb.entity.types.RefSType(int, java.lang.String)

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

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

    /**
     * Method getType
     * <p/>
     * Returns the type of this RefSType
     *
     * @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("1:1", VALUE_0);
        members.put("1:n", VALUE_1);
        members.put("n:1", VALUE_2);
        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 RefSType
     *
     * @return String
     */
    public java.lang.String toString() {
        return this.stringValue;
    } //-- java.lang.String toString() 

    /**
     * Method valueOf
     * <p/>
     * Returns a new RefSType based on the given String value.
     *
     * @param string
     * @return RefSType
     */
    public static com.queplix.core.jxb.entity.types.RefSType 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 RefSType";
            throw new IllegalArgumentException(err);
        }
        return (RefSType) obj;
    } //-- com.queplix.core.jxb.entity.types.RefSType valueOf(java.lang.String) 

}
