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:package org.apache.naming.util;
018:
019:import java.util.Enumeration;
020:import java.util.Vector;
021:
022:import javax.naming.NamingEnumeration;
023:import javax.naming.NamingException;
024:
025:/**
026: * Naming enumeration implementation.
027: *
028: * @author Remy Maucherat
029: * @version $Revision: 1.3 $ $Date: 2004/02/24 08:58:09 $
030: */
031:
032:public class RecyclableNamingEnumeration
033: implements NamingEnumeration {
034:
035:
036: // ----------------------------------------------------------- Constructors
037:
038:
039: public RecyclableNamingEnumeration(Vector entries) {
040: this .entries = entries;
041: recycle();
042: }
043:
044:
045: // -------------------------------------------------------------- Variables
046:
047:
048: /**
049: * Entries.
050: */
051: protected Vector entries;
052:
053:
054: /**
055: * Underlying enumeration.
056: */
057: protected Enumeration enum;
058:
059:
060: // --------------------------------------------------------- Public Methods
061:
062:
063: /**
064: * Retrieves the next element in the enumeration.
065: */
066: public Object next()
067: throws NamingException {
068: return nextElement();
069: }
070:
071:
072: /**
073: * Determines whether there are any more elements in the enumeration.
074: */
075: public boolean hasMore()
076: throws NamingException {
077: return enum.hasMoreElements();
078: }
079:
080:
081: /**
082: * Closes this enumeration.
083: */
084: public void close()
085: throws NamingException {
086: }
087:
088:
089: public boolean hasMoreElements() {
090: return enum.hasMoreElements();
091: }
092:
093:
094: public Object nextElement() {
095: return enum.nextElement();
096: }
097:
098:
099: // -------------------------------------------------------- Package Methods
100:
101:
102: /**
103: * Recycle.
104: */
105: void recycle() {
106: enum = entries.elements();
107: }
108:
109:
110:}
|