001:/*
002: * The contents of this file are subject to the Sapient Public License
003: * Version 1.0 (the "License"); you may not use this file except in compliance
004: * with the License. You may obtain a copy of the License at
005: * http://carbon.sf.net/License.html.
006: *
007: * Software distributed under the License is distributed on an "AS IS" basis,
008: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
009: * the specific language governing rights and limitations under the License.
010: *
011: * The Original Code is The Carbon Component Framework.
012: *
013: * The Initial Developer of the Original Code is Sapient Corporation
014: *
015: * Copyright (C) 2003 Sapient Corporation. All Rights Reserved.
016: */
017:
018:package org.sape.carbon.services.sql;
019:
020:
021:import java.io.ObjectStreamException;
022:import java.io.Serializable;
023:import java.sql.ResultSet;
024:import java.util.Iterator;
025:
026:import org.sape.carbon.core.util.enum.BaseEnum;
027:import org.sape.carbon.core.util.enum.EnumNotFoundException;
028:
029:
030:/**
031: * <P>This enumeration represents the types of concurrency supported in
032: * JDBC connections.</P>
033: *
034: * Copyright 2002 Sapient
035: * @see java.sql.ResultSet
036: * @since carbon 1.0
037: * @author Greg Hinkle, July 2002
038: * @version $Revision: 1.6 $($Author: dvoet $ / $Date: 2003/05/05 21:21:36 $)
039: */
040:public class ResultSetConcurrencyEnum extends BaseEnum implements Serializable {
041:
042:
043: /**
044: * Represents the read-only type of concurrency
045: * @see java.sql.ResultSet#CONCUR_READ_ONLY
046: */
047: public static final ResultSetConcurrencyEnum CONCUR_READ_ONLY =
048: new ResultSetConcurrencyEnum("CONCUR_READ_ONLY",
049: ResultSet.CONCUR_READ_ONLY);
050:
051: /**
052: * Represents the updatable type of concurrency
053: * @see java.sql.ResultSet#CONCUR_UPDATABLE
054: */
055: public static final ResultSetConcurrencyEnum CONCUR_UPDATABLE =
056: new ResultSetConcurrencyEnum("CONCUR_UPDATABLE",
057: ResultSet.CONCUR_UPDATABLE);
058:
059: /**
060: * Constructs a enumeration of type <code>ResultSetConcurrencyEnum</code>
061: *
062: * @param name the String representation of this enumeration
063: * @param ordinal the integer ordinal value of a specific
064: */
065: private ResultSetConcurrencyEnum(String name, int ordinal) {
066: super (ResultSetConcurrencyEnum.class, name, ordinal);
067: }
068:
069:
070: /**
071: * Looks up a <code>ResultSetConcurrencyEnum</code> by its
072: * string representation
073: *
074: * @param name the String name of a enumeration instance
075: * @return an specific <code>ResultSetConcurrencyEnum</code>
076: * @throws ResultSetConcurrencyEnumNotFoundException when there is no
077: * enumeration instance for the given name
078: */
079: public static final ResultSetConcurrencyEnum getByName(String name)
080: throws ResultSetConcurrencyEnumNotFoundException {
081:
082: ResultSetConcurrencyEnum enum = (ResultSetConcurrencyEnum)
083: BaseEnum.getByName(name, ResultSetConcurrencyEnum.class);
084: if (enum != null) {
085: return enum;
086: } else {
087: throw new ResultSetConcurrencyEnumNotFoundException(name);
088: }
089: }
090:
091: /**
092: * Looks up a <code>ResultSetConcurrencyEnum</code> by its
093: * ordinal representation
094: *
095: * @param ordinal the integer ordinal value of a specific
096: * enumeration instance
097: * @return an specific <code>ResultSetConcurrencyEnum</code>
098: * @throws ResultSetConcurrencyEnumNotFoundException when there is no
099: * enumeration instance for the given ordinal
100: */
101: public static ResultSetConcurrencyEnum getByOrdinal(int ordinal)
102: throws ResultSetConcurrencyEnumNotFoundException {
103:
104: ResultSetConcurrencyEnum enum = (ResultSetConcurrencyEnum)
105: BaseEnum.getByOrdinal(ordinal, ResultSetConcurrencyEnum.class);
106: if (enum != null) {
107: return enum;
108: } else {
109: throw new ResultSetConcurrencyEnum.
110: ResultSetConcurrencyEnumNotFoundException(
111: (new Long(ordinal)).toString());
112: }
113: }
114:
115: /**
116: * Retrieves and iterator by ascending ordinal order for all enumerations
117: * of this type.
118: *
119: * @return an iterator over all <code>ResultSetConcurrencyEnum</code>
120: */
121: public static Iterator iterator() {
122: return BaseEnum.iterator(ResultSetConcurrencyEnum.class);
123: }
124:
125: /**
126: * Overrides part of serialization to return a reference to an
127: * enumeration instance that is managed by the Enumeration Subsystem.
128: * This will always return the SAME object instance for any single
129: * enum instance and is what allows the "==" operator to be used for
130: * comparisons.
131: *
132: * @throws ObjectStreamException indicates there is a failure to
133: * resolve the streamed object due to a format or read io
134: * exception
135: * @return the object instance that should be resolved by this class
136: */
137: final Object readResolve() throws ObjectStreamException {
138: return super .getByOrdinal(this .ordinal, ResultSetConcurrencyEnum.class);
139: }
140:
141: /**
142: * This class is a typesafe retriever excepection for an enumeration
143: */
144: public static class ResultSetConcurrencyEnumNotFoundException
145: extends EnumNotFoundException {
146:
147: /**
148: * @see EnumNotFoundException#EnumNotFoundException
149: */
150: public ResultSetConcurrencyEnumNotFoundException(String name) {
151: super (ResultSetConcurrencyEnum.class, name);
152: }
153: }
154:
155:
156:}
|