01: /**
02: * Sequoia: Database clustering technology.
03: * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
04: * Contact: sequoia@continuent.org
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
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: */package org.continuent.sequoia.common.util;
21:
22: import java.sql.Connection;
23:
24: /**
25: * Provides transaction isolation level to string converter
26: *
27: * @author <a href="mailto:gilles.rayrat@continuent.com">Gilles Rayrat</a>
28: */
29: public class TransactionIsolationLevelConverter {
30: /**
31: * Converts the given transaction isolation level to a human readable string,
32: * identical to the constant name found in Connection or
33: * "TRANSACTION_UNDEFINED" if the level does not exist
34: *
35: * @param level one of the transaction isolation level as found in
36: * <code>java.sql.Connection</code>
37: * @return a string representation of the given level, one of:
38: * <code>"TRANSACTION_READ_UNCOMMITTED"</code>,
39: * <code>"TRANSACTION_READ_COMMITTED"</code>,
40: * <code>"TRANSACTION_REPEATABLE_READ"</code>,
41: * <code>"TRANSACTION_SERIALIZABLE"</code>,
42: * <code>"TRANSACTION_NONE"</code>,
43: * <code>"TRANSACTION_UNDEFINED"</code> because it specifies that
44: * transactions are not supported.)
45: * @see java.sql.Connection#getTransactionIsolation()
46: */
47: public static String toString(int level) {
48: switch (level) {
49: case Connection.TRANSACTION_READ_UNCOMMITTED:
50: return "TRANSACTION_READ_UNCOMMITTED";
51: case Connection.TRANSACTION_READ_COMMITTED:
52: return "TRANSACTION_READ_COMMITTED";
53: case Connection.TRANSACTION_REPEATABLE_READ:
54: return "TRANSACTION_REPEATABLE_READ";
55: case Connection.TRANSACTION_SERIALIZABLE:
56: return "TRANSACTION_SERIALIZABLE";
57: case Connection.TRANSACTION_NONE:
58: return "TRANSACTION_NONE";
59: default:
60: return "TRANSACTION_UNDEFINED";
61: }
62: }
63: }
|