KickJava   Java API By Example, From Geeks To Geeks.

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


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

17
18
19 package org.apache.naming.resources;
20
21 import java.util.Enumeration JavaDoc;
22 import java.util.Vector JavaDoc;
23
24 import javax.naming.NamingEnumeration JavaDoc;
25 import javax.naming.NamingException JavaDoc;
26
27 /**
28  * Naming enumeration implementation.
29  *
30  * @author Remy Maucherat
31  * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
32  */

33
34 public class RecyclableNamingEnumeration
35     implements NamingEnumeration JavaDoc {
36
37
38     // ----------------------------------------------------------- Constructors
39

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

49
50     /**
51      * Entries.
52      */

53     protected Vector JavaDoc entries;
54
55
56     /**
57      * Underlying enumeration.
58      */

59     protected Enumeration JavaDoc enumeration;
60
61
62     // --------------------------------------------------------- Public Methods
63

64
65     /**
66      * Retrieves the next element in the enumeration.
67      */

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

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

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

103
104     /**
105      * Recycle.
106      */

107     void recycle() {
108         enumeration = entries.elements();
109     }
110
111
112 }
113
114
Popular Tags