001:/*
002: * Copyright 1999,2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017:
018:package org.apache.naming.resources;
019:
020:import java.util.Enumeration;
021:import java.util.Vector;
022:
023:import javax.naming.NamingEnumeration;
024:import javax.naming.NamingException;
025:
026:/**
027: * Naming enumeration implementation.
028: *
029: * @author Remy Maucherat
030: * @version $Revision: 1.3 $ $Date: 2004/02/27 14:58:54 $
031: */
032:
033:public class RecyclableNamingEnumeration
034: implements NamingEnumeration {
035:
036:
037: // ----------------------------------------------------------- Constructors
038:
039:
040: public RecyclableNamingEnumeration(Vector entries) {
041: this .entries = entries;
042: recycle();
043: }
044:
045:
046: // -------------------------------------------------------------- Variables
047:
048:
049: /**
050: * Entries.
051: */
052: protected Vector entries;
053:
054:
055: /**
056: * Underlying enumeration.
057: */
058: protected Enumeration enum;
059:
060:
061: // --------------------------------------------------------- Public Methods
062:
063:
064: /**
065: * Retrieves the next element in the enumeration.
066: */
067: public Object next()
068: throws NamingException {
069: return nextElement();
070: }
071:
072:
073: /**
074: * Determines whether there are any more elements in the enumeration.
075: */
076: public boolean hasMore()
077: throws NamingException {
078: return enum.hasMoreElements();
079: }
080:
081:
082: /**
083: * Closes this enumeration.
084: */
085: public void close()
086: throws NamingException {
087: }
088:
089:
090: public boolean hasMoreElements() {
091: return enum.hasMoreElements();
092: }
093:
094:
095: public Object nextElement() {
096: return enum.nextElement();
097: }
098:
099:
100: // -------------------------------------------------------- Package Methods
101:
102:
103: /**
104: * Recycle.
105: */
106: void recycle() {
107: enum = entries.elements();
108: }
109:
110:
111:}
|