KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > terracotta > dso > views > LocksWrapper


1 /*
2  * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package org.terracotta.dso.views;
5
6 import com.terracottatech.config.Autolock;
7 import com.terracottatech.config.DsoApplication;
8 import com.terracottatech.config.Locks;
9 import com.terracottatech.config.NamedLock;
10
11 public class LocksWrapper {
12   private DsoApplication fApp;
13   
14   LocksWrapper(DsoApplication app) {
15     fApp = app;
16   }
17   
18   int sizeOfLocksArray() {
19     Locks locks = fApp.getLocks();
20     return locks != null ? locks.sizeOfAutolockArray()+locks.sizeOfNamedLockArray(): 0;
21   }
22   
23   int sizeOfAutolockArray() {
24     Locks locks = fApp.getLocks();
25     return locks != null ? locks.sizeOfAutolockArray() : 0;
26   }
27   
28   Autolock getAutolockArray(int i) {
29     Locks locks = fApp.getLocks();
30     return locks != null ? locks.getAutolockArray(i) : null;
31   }
32   
33   void removeAutolock(int i) {
34     Locks locks = fApp.getLocks();
35     if(locks != null) {
36       locks.removeAutolock(i);
37     }
38     if(sizeOfLocksArray() == 0) {
39       fApp.unsetLocks();
40     }
41   }
42   
43   int sizeOfNamedLockArray() {
44     Locks locks = fApp.getLocks();
45     return locks != null ? locks.sizeOfNamedLockArray() : 0;
46   }
47   
48   NamedLock getNamedLockArray(int i) {
49     Locks locks = fApp.getLocks();
50     return locks != null ? locks.getNamedLockArray(i) : null;
51   }
52   
53   void removeNamedLock(int i) {
54     Locks locks = fApp.getLocks();
55     if(locks != null) {
56       locks.removeNamedLock(i);
57     }
58     if(sizeOfLocksArray() == 0) {
59       fApp.unsetLocks();
60     }
61   }
62 }
63
Popular Tags