KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > iapi > services > locks > ShExQual


1 /*
2
3    Derby - Class org.apache.derby.iapi.services.locks.ShExQual
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.iapi.services.locks;
23
24 /**
25  * This class is intended to be used a the qualifier class for ShExLockable.
26  */

27 public class ShExQual
28 {
29     private int lockState;
30
31     private ShExQual(int lockState)
32     {
33         this.lockState = lockState;
34     }
35
36     /*
37     ** These are intentionally package protected. They are intended to
38     ** be used in this class and by ShExLockable, and by no one else.
39     */

40     public static final int SHARED = 0;
41     public static final int EXCLUSIVE = 1;
42
43     /* Shared Lock */
44     public static final ShExQual SH = new ShExQual(SHARED);
45
46     /* Exclusive Lock */
47     public static final ShExQual EX = new ShExQual(EXCLUSIVE);
48
49     public int getLockState()
50     {
51         return lockState;
52     }
53
54     public String JavaDoc toString()
55     {
56         if (lockState == SHARED)
57             return "S";
58         else
59             return "X";
60     }
61 }
62
Popular Tags