KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > naming > util > RecyclableNamingEnumeration


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.naming.util;
18
19 import java.util.Enumeration;
20 import java.util.Vector;
21
22 import javax.naming.NamingEnumeration;
23 import javax.naming.NamingException;
24
25 /**
26  * Naming enumeration implementation.
27  *
28  * @author Remy Maucherat
29  * @version $Revision: 1.3 $ $Date: 2004/02/24 08:58:09 $
30  */

31
32 public class RecyclableNamingEnumeration
33     implements NamingEnumeration {
34
35
36     // ----------------------------------------------------------- Constructors
37

38
39     public RecyclableNamingEnumeration(Vector entries) {
40         this.entries = entries;
41         recycle();
42     }
43
44
45     // -------------------------------------------------------------- Variables
46

47
48     /**
49      * Entries.
50      */

51     protected Vector entries;
52
53
54     /**
55      * Underlying enumeration.
56      */

57     protected Enumeration enum;
58
59
60     // --------------------------------------------------------- Public Methods
61

62
63     /**
64      * Retrieves the next element in the enumeration.
65      */

66     public Object next()
67         throws NamingException {
68         return nextElement();
69     }
70
71
72     /**
73      * Determines whether there are any more elements in the enumeration.
74      */

75     public boolean hasMore()
76         throws NamingException {
77         return enum.hasMoreElements();
78     }
79
80
81     /**
82      * Closes this enumeration.
83      */

84     public void close()
85         throws NamingException {
86     }
87
88
89     public boolean hasMoreElements() {
90         return enum.hasMoreElements();
91     }
92
93
94     public Object nextElement() {
95         return enum.nextElement();
96     }
97
98
99     // -------------------------------------------------------- Package Methods
100

101
102     /**
103      * Recycle.
104      */

105     void recycle() {
106         enum = entries.elements();
107     }
108
109
110 }
111
112
Popular Tags