1 | /* |
2 | |
3 | Derby - Class org.apache.derby.iapi.services.locks.ShExQual |
4 | |
5 | Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable. |
6 | |
7 | Licensed under the Apache License, Version 2.0 (the "License"); |
8 | you may not use this file except in compliance with the License. |
9 | You may obtain a copy of the License at |
10 | |
11 | http://www.apache.org/licenses/LICENSE-2.0 |
12 | |
13 | Unless required by applicable law or agreed to in writing, software |
14 | distributed under the License is distributed on an "AS IS" BASIS, |
15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | See the License for the specific language governing permissions and |
17 | limitations under the License. |
18 | |
19 | */ |
20 | |
21 | package org.apache.derby.iapi.services.locks; |
22 | |
23 | /** |
24 | * This class is intended to be used a the qualifier class for ShExLockable. |
25 | */ |
26 | public class ShExQual |
27 | { |
28 | private int lockState; |
29 | |
30 | private ShExQual(int lockState) |
31 | { |
32 | this.lockState = lockState; |
33 | } |
34 | |
35 | /* |
36 | ** These are intentionally package protected. They are intended to |
37 | ** be used in this class and by ShExLockable, and by no one else. |
38 | */ |
39 | public static final int SHARED = 0; |
40 | public static final int EXCLUSIVE = 1; |
41 | |
42 | /* Shared Lock */ |
43 | public static final ShExQual SH = new ShExQual(SHARED); |
44 | |
45 | /* Exclusive Lock */ |
46 | public static final ShExQual EX = new ShExQual(EXCLUSIVE); |
47 | |
48 | public int getLockState() |
49 | { |
50 | return lockState; |
51 | } |
52 | |
53 | public String toString() |
54 | { |
55 | if (lockState == SHARED) |
56 | return "S"; |
57 | else |
58 | return "X"; |
59 | } |
60 | } |