ResultSetConcurrencyEnum.java :  » Inversion-of-Control » carbon » org » sape » carbon » services » sql » Java Open Source

Java Open Source » Inversion of Control » carbon 
carbon » org » sape » carbon » services » sql » ResultSetConcurrencyEnum.java
/*
 * The contents of this file are subject to the Sapient Public License
 * Version 1.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://carbon.sf.net/License.html.
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 *
 * The Original Code is The Carbon Component Framework.
 *
 * The Initial Developer of the Original Code is Sapient Corporation
 *
 * Copyright (C) 2003 Sapient Corporation. All Rights Reserved.
 */

package org.sape.carbon.services.sql;


import java.io.ObjectStreamException;
import java.io.Serializable;
import java.sql.ResultSet;
import java.util.Iterator;

import org.sape.carbon.core.util.enum.BaseEnum;
import org.sape.carbon.core.util.enum.EnumNotFoundException;


/**
 * <P>This enumeration represents the types of concurrency supported in
 * JDBC connections.</P>
 *
 * Copyright 2002 Sapient
 * @see java.sql.ResultSet
 * @since carbon 1.0
 * @author Greg Hinkle, July 2002
 * @version $Revision: 1.6 $($Author: dvoet $ / $Date: 2003/05/05 21:21:36 $)
 */
public class ResultSetConcurrencyEnum extends BaseEnum implements Serializable {


    /**
     * Represents the read-only type of concurrency
     * @see java.sql.ResultSet#CONCUR_READ_ONLY
     */
    public static final ResultSetConcurrencyEnum CONCUR_READ_ONLY =
        new ResultSetConcurrencyEnum("CONCUR_READ_ONLY",
                ResultSet.CONCUR_READ_ONLY);

    /**
     * Represents the updatable type of concurrency
     * @see java.sql.ResultSet#CONCUR_UPDATABLE
     */
    public static final ResultSetConcurrencyEnum CONCUR_UPDATABLE =
        new ResultSetConcurrencyEnum("CONCUR_UPDATABLE",
                ResultSet.CONCUR_UPDATABLE);

    /**
     * Constructs a enumeration of type <code>ResultSetConcurrencyEnum</code>
     *
     * @param name the String representation of this enumeration
     * @param ordinal the integer ordinal value of a specific
     */
    private ResultSetConcurrencyEnum(String name, int ordinal) {
        super(ResultSetConcurrencyEnum.class, name, ordinal);
    }


    /**
     * Looks up a <code>ResultSetConcurrencyEnum</code> by its
     * string representation
     *
     * @param name the String name of a enumeration instance
     * @return an specific <code>ResultSetConcurrencyEnum</code>
     * @throws ResultSetConcurrencyEnumNotFoundException when there is no
     *         enumeration instance for the given name
     */
    public static final ResultSetConcurrencyEnum getByName(String name)
            throws ResultSetConcurrencyEnumNotFoundException {

        ResultSetConcurrencyEnum enum =  (ResultSetConcurrencyEnum)
        BaseEnum.getByName(name, ResultSetConcurrencyEnum.class);
        if (enum != null) {
            return enum;
        } else {
            throw new ResultSetConcurrencyEnumNotFoundException(name);
        }
    }

    /**
     * Looks up a <code>ResultSetConcurrencyEnum</code> by its
     * ordinal representation
     *
     * @param ordinal the integer ordinal value of a specific
     *        enumeration instance
     * @return an specific <code>ResultSetConcurrencyEnum</code>
     * @throws ResultSetConcurrencyEnumNotFoundException when there is no
     *         enumeration instance for the given ordinal
     */
    public static ResultSetConcurrencyEnum getByOrdinal(int ordinal)
            throws ResultSetConcurrencyEnumNotFoundException {

        ResultSetConcurrencyEnum enum =  (ResultSetConcurrencyEnum)
        BaseEnum.getByOrdinal(ordinal, ResultSetConcurrencyEnum.class);
        if (enum != null) {
            return enum;
        } else {
            throw new ResultSetConcurrencyEnum.
                ResultSetConcurrencyEnumNotFoundException(
                    (new Long(ordinal)).toString());
        }
    }

    /**
     * Retrieves and iterator by ascending ordinal order for all enumerations
     * of this type.
     *
     * @return an iterator over all <code>ResultSetConcurrencyEnum</code>
     */
    public static Iterator iterator() {
        return BaseEnum.iterator(ResultSetConcurrencyEnum.class);
    }

    /**
     * Overrides part of serialization to return a reference to an
     * enumeration instance that is managed by the Enumeration Subsystem.
     * This will always return the SAME object instance for any single
     * enum instance and is what allows the "==" operator to be used for
     * comparisons.
     *
     * @throws ObjectStreamException indicates there is a failure to
     *         resolve the streamed object due to a format or read io
     *         exception
     * @return the object instance that should be resolved by this class
     */
    final Object readResolve() throws ObjectStreamException {
        return super.getByOrdinal(this.ordinal, ResultSetConcurrencyEnum.class);
    }

    /**
     * This class is a typesafe retriever excepection for an enumeration
     */
    public static class ResultSetConcurrencyEnumNotFoundException
            extends EnumNotFoundException {

        /**
         * @see EnumNotFoundException#EnumNotFoundException
         */
        public ResultSetConcurrencyEnumNotFoundException(String name) {
            super(ResultSetConcurrencyEnum.class, name);
        }
    }


}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.