01: package com.flexive.war.webdav.catalina;
02:
03: import javax.naming.NamingEnumeration;
04: import javax.naming.NamingException;
05: import java.util.Enumeration;
06: import java.util.Vector;
07:
08: /**
09: * Catalina sources cloned for packaging issues to the flexive source tree.
10: * Refactored to JDK 1.5 compatibility.
11: * Licensed under the Apache License, Version 2.0
12: * <p/>
13: * Naming enumeration implementation.
14: *
15: * @author Remy Maucherat
16: * @author Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
17: */
18: public class RecyclableNamingEnumeration implements NamingEnumeration {
19:
20: // ----------------------------------------------------------- Constructors
21:
22: public RecyclableNamingEnumeration(Vector entries) {
23: this .entries = entries;
24: recycle();
25: }
26:
27: // -------------------------------------------------------------- Variables
28:
29: /**
30: * Entries.
31: */
32: protected Vector entries;
33:
34: /**
35: * Underlying enumeration.
36: */
37: protected Enumeration enumeration;
38:
39: // --------------------------------------------------------- Public Methods
40:
41: /**
42: * Retrieves the next element in the enumeration.
43: */
44: public Object next() throws NamingException {
45: return nextElement();
46: }
47:
48: /**
49: * Determines whether there are any more elements in the enumeration.
50: */
51: public boolean hasMore() throws NamingException {
52: return enumeration.hasMoreElements();
53: }
54:
55: /**
56: * Closes this enumeration.
57: */
58: public void close() throws NamingException {
59: }
60:
61: public boolean hasMoreElements() {
62: return enumeration.hasMoreElements();
63: }
64:
65: public Object nextElement() {
66: return enumeration.nextElement();
67: }
68:
69: // -------------------------------------------------------- Package Methods
70:
71: /**
72: * Recycle.
73: */
74: void recycle() {
75: enumeration = entries.elements();
76: }
77:
78: }
|