1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.security.impl;
18
19 import java.util.Collection;
20 import java.util.HashSet;
21 import java.util.Iterator;
22 import java.util.LinkedList;
23 import java.util.List;
24 import java.util.Set;
25
26
27 /***
28 * PrincipalsSet - provides an ordered 'set' of principals required
29 * for some profiling rules that are dependent on order of insert.
30 *
31 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
32 * @version $Id: $
33 */
34
35 public class PrincipalsSet implements Set
36 {
37 List principals = new LinkedList();
38 Set set = new HashSet();
39
40 public PrincipalsSet()
41 {}
42
43
44
45
46 public int size()
47 {
48 return principals.size();
49 }
50
51
52
53
54 public void clear()
55 {
56 set.clear();
57 principals.clear();
58 }
59
60
61
62
63 public boolean isEmpty()
64 {
65 return principals.isEmpty();
66 }
67
68
69
70
71 public Object[] toArray()
72 {
73 return principals.toArray();
74 }
75
76
77
78
79 public boolean add(Object o)
80 {
81 if (set.add(o))
82 {
83 principals.add(o);
84 return true;
85 }
86 return false;
87 }
88
89
90
91
92 public boolean contains(Object o)
93 {
94 return set.contains(o);
95 }
96
97
98
99
100 public boolean remove(Object o)
101 {
102 set.remove(o);
103 return principals.remove(o);
104 }
105
106
107
108
109 public boolean addAll(Collection c)
110 {
111 set.addAll(c);
112 return principals.addAll(c);
113 }
114
115
116
117
118 public boolean containsAll(Collection c)
119 {
120 return set.containsAll(c);
121 }
122
123
124
125
126 public boolean removeAll(Collection c)
127 {
128 set.removeAll(c);
129 return principals.removeAll(c);
130 }
131
132
133
134
135 public boolean retainAll(Collection c)
136 {
137 set.retainAll(c);
138 return principals.retainAll(c);
139 }
140
141
142
143
144 public Iterator iterator()
145 {
146 return principals.iterator();
147 }
148
149
150
151
152 public Object[] toArray(Object[] a)
153 {
154 return principals.toArray(a);
155 }
156
157 }