KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > filesys > smb > dcerpc > PolicyHandleCache


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.filesys.smb.dcerpc;
18
19 import java.util.Enumeration JavaDoc;
20 import java.util.Hashtable JavaDoc;
21
22 /**
23  * Policy Handle Cache Class
24  */

25 public class PolicyHandleCache
26 {
27
28     // Policy handles
29

30     private Hashtable JavaDoc<String JavaDoc, PolicyHandle> m_cache;
31
32     /**
33      * Default constructor
34      */

35     public PolicyHandleCache()
36     {
37         m_cache = new Hashtable JavaDoc<String JavaDoc, PolicyHandle>();
38     }
39
40     /**
41      * Return the number of handles in the cache
42      *
43      * @return int
44      */

45     public final int numberOfHandles()
46     {
47         return m_cache.size();
48     }
49
50     /**
51      * Add a handle to the cache
52      *
53      * @param name String
54      * @param handle PolicyHandle
55      */

56     public final void addHandle(String JavaDoc name, PolicyHandle handle)
57     {
58         m_cache.put(name, handle);
59     }
60
61     /**
62      * Return the handle for the specified index
63      *
64      * @param index String
65      * @return PolicyHandle
66      */

67     public final PolicyHandle findHandle(String JavaDoc index)
68     {
69         return m_cache.get(index);
70     }
71
72     /**
73      * Delete a handle from the cache
74      *
75      * @param index String
76      * @return PolicyHandle
77      */

78     public final PolicyHandle removeHandle(String JavaDoc index)
79     {
80         return m_cache.remove(index);
81     }
82
83     /**
84      * Enumerate the handles in the cache
85      *
86      * @return Enumeration<PolicyHandle>
87      */

88     public final Enumeration JavaDoc<PolicyHandle> enumerateHandles()
89     {
90         return m_cache.elements();
91     }
92
93     /**
94      * Clear all handles from the cache
95      */

96     public final void removeAllHandles()
97     {
98         m_cache.clear();
99     }
100 }
101
Popular Tags