KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > common > util > TransactionIsolationLevelConverter


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
4  * Contact: sequoia@continuent.org
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * Initial developer(s): Emmanuel Cecchet.
19  * Contributor(s): ______________________.
20  */

21
22 package org.continuent.sequoia.common.util;
23
24 import java.sql.Connection JavaDoc;
25
26 /**
27  * Provides transaction isolation level to string converter
28  *
29  * @author <a HREF="mailto:gilles.rayrat@continuent.com">Gilles Rayrat</a>
30  */

31 public class TransactionIsolationLevelConverter
32 {
33   /**
34    * Converts the given transaction isolation level to a human readable string,
35    * identical to the constant name found in Connection or
36    * "TRANSACTION_UNDEFINED" if the level does not exist
37    *
38    * @param level one of the transaction isolation level as found in
39    * <code>java.sql.Connection</code>
40    * @return a string representation of the given level, one of:
41    * <code>"TRANSACTION_READ_UNCOMMITTED"</code>,
42    * <code>"TRANSACTION_READ_COMMITTED"</code>,
43    * <code>"TRANSACTION_REPEATABLE_READ"</code>,
44    * <code>"TRANSACTION_SERIALIZABLE"</code>,
45    * <code>"TRANSACTION_NONE"</code>,
46    * <code>"TRANSACTION_UNDEFINED"</code> because it specifies that
47    * transactions are not supported.)
48    * @see java.sql.Connection#getTransactionIsolation()
49    */

50   public static String JavaDoc toString(int level)
51   {
52     switch (level)
53     {
54       case Connection.TRANSACTION_READ_UNCOMMITTED :
55         return "TRANSACTION_READ_UNCOMMITTED";
56       case Connection.TRANSACTION_READ_COMMITTED :
57         return "TRANSACTION_READ_COMMITTED";
58       case Connection.TRANSACTION_REPEATABLE_READ :
59         return "TRANSACTION_REPEATABLE_READ";
60       case Connection.TRANSACTION_SERIALIZABLE :
61         return "TRANSACTION_SERIALIZABLE";
62       case Connection.TRANSACTION_NONE :
63         return "TRANSACTION_NONE";
64       default :
65         return "TRANSACTION_UNDEFINED";
66     }
67   }
68 }
69
Popular Tags