01: /**
02: * Objective Database Abstraction Layer (ODAL)
03: * Copyright (c) 2004, The ODAL Development Group
04: * All rights reserved.
05: * For definition of the ODAL Development Group please refer to LICENCE.txt file
06: *
07: * Distributable under LGPL license.
08: * See terms of license at gnu.org.
09: */package com.completex.objective.components.persistency;
10:
11: import java.io.Serializable;
12: import java.util.HashMap;
13:
14: /**
15: * Represents database lock type
16: *
17: * @author Gennady Krizhevsky
18: */
19: public class LockType implements Serializable {
20:
21: private String name;
22:
23: private LockType(String name) {
24: this .name = name;
25: }
26:
27: /**
28: * Lock types
29: */
30: public static final LockType NONE = new LockType("NONE");
31: public static final LockType FOR_UPDATE = new LockType("FOR_UPDATE");
32: public static final LockType FOR_UPDATE_NOWAIT = new LockType(
33: "FOR_UPDATE_NOWAIT");
34:
35: private static final HashMap TYPES = new HashMap();
36:
37: static {
38: TYPES.put(NONE.getName(), NONE);
39: TYPES.put(FOR_UPDATE.getName(), FOR_UPDATE);
40: TYPES.put(FOR_UPDATE_NOWAIT.getName(), FOR_UPDATE_NOWAIT);
41: }
42:
43: public String toString() {
44: return name;
45: }
46:
47: public static boolean isWait(LockType lockType) {
48: return lockType == FOR_UPDATE;
49: }
50:
51: public String getName() {
52: return name;
53: }
54:
55: public static LockType name2type(String name) {
56: return (LockType) TYPES.get(name);
57: }
58:
59: }
|