KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > server > ss > util > ASSet


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.server.ss.util;
24                                                                                                                              
25 /**
26  * When nio application uses Selector.selectedKeys(),
27  * ASSelector will return a ASSet instance, where it will wrap
28  * those selection keys used for OP_ACCEPT.
29  * Nio application might use Set.iterator() to remove the
30  * processed SelectionKey from the selectedSet. We provide
31  * a wrapper Iterator so that even the actual selectedSet in
32  * the Selector is modified.
33  *
34  * @see ASSelector
35  */

36 public class ASSet implements java.util.Set JavaDoc {
37
38     private java.util.Set JavaDoc set = null;
39     private ASWrapperCreator wCreator = null;
40
41     public ASSet(java.util.Set JavaDoc set, ASWrapperCreator wCreator) {
42         this.set = set;
43         this.wCreator = wCreator;
44     }
45
46     public int size() {
47         return set.size();
48     }
49
50     public boolean isEmpty() {
51         return set.isEmpty();
52     }
53
54     public boolean contains(java.lang.Object JavaDoc obj) {
55         return set.contains(obj);
56     }
57
58     public java.util.Iterator JavaDoc iterator() {
59         return new ASIterator(this);
60     }
61
62     public Object JavaDoc[] toArray() {
63         return set.toArray();
64     }
65
66     public Object JavaDoc[] toArray(java.lang.Object JavaDoc[] a) {
67         return set.toArray(a);
68     }
69
70     public boolean add(java.lang.Object JavaDoc obj) {
71         return set.add(obj);
72     }
73
74     public boolean remove(java.lang.Object JavaDoc obj) {
75         return set.remove(obj);
76     }
77
78     public boolean containsAll(java.util.Collection JavaDoc c) {
79         return set.containsAll(c);
80     }
81
82     public boolean addAll(java.util.Collection JavaDoc c) {
83         return set.addAll(c);
84     }
85
86     public boolean retainAll(java.util.Collection JavaDoc c) {
87         return set.retainAll(c);
88     }
89
90     public boolean removeAll(java.util.Collection JavaDoc c) {
91         return set.removeAll(c);
92     }
93
94     public void clear() {
95         set.clear();
96     }
97
98     public boolean equals(java.lang.Object JavaDoc obj) {
99         return set.equals(obj);
100     }
101
102     public int hashCode() {
103         return set.hashCode();
104     }
105
106     java.util.Set JavaDoc actualSet() {
107         return set;
108     }
109
110     Object JavaDoc wrapIfNecessary(Object JavaDoc next) {
111         return wCreator.wrapIfNecessary(next);
112     }
113 }
114
Popular Tags