01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: package org.apache.naming.resources;
19:
20: import java.util.Enumeration;
21: import java.util.Vector;
22:
23: import javax.naming.NamingEnumeration;
24: import javax.naming.NamingException;
25:
26: /**
27: * Naming enumeration implementation.
28: *
29: * @author Remy Maucherat
30: * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
31: */
32:
33: public class RecyclableNamingEnumeration implements NamingEnumeration {
34:
35: // ----------------------------------------------------------- Constructors
36:
37: public RecyclableNamingEnumeration(Vector entries) {
38: this .entries = entries;
39: recycle();
40: }
41:
42: // -------------------------------------------------------------- Variables
43:
44: /**
45: * Entries.
46: */
47: protected Vector entries;
48:
49: /**
50: * Underlying enumeration.
51: */
52: protected Enumeration enumeration;
53:
54: // --------------------------------------------------------- Public Methods
55:
56: /**
57: * Retrieves the next element in the enumeration.
58: */
59: public Object next() throws NamingException {
60: return nextElement();
61: }
62:
63: /**
64: * Determines whether there are any more elements in the enumeration.
65: */
66: public boolean hasMore() throws NamingException {
67: return enumeration.hasMoreElements();
68: }
69:
70: /**
71: * Closes this enumeration.
72: */
73: public void close() throws NamingException {
74: }
75:
76: public boolean hasMoreElements() {
77: return enumeration.hasMoreElements();
78: }
79:
80: public Object nextElement() {
81: return enumeration.nextElement();
82: }
83:
84: // -------------------------------------------------------- Package Methods
85:
86: /**
87: * Recycle.
88: */
89: void recycle() {
90: enumeration = entries.elements();
91: }
92:
93: }
|