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;
019:
020:import java.util.Enumeration;
021:import java.util.Vector;
022:
023:import javax.naming.NameClassPair;
024:import javax.naming.NamingEnumeration;
025:import javax.naming.NamingException;
026:
027:/**
028: * Naming enumeration implementation.
029: *
030: * @author Remy Maucherat
031: * @version $Revision: 1.3 $ $Date: 2004/02/27 14:58:53 $
032: */
033:
034:public class NamingContextEnumeration
035: implements NamingEnumeration {
036:
037:
038: // ----------------------------------------------------------- Constructors
039:
040:
041: public NamingContextEnumeration(Vector entries) {
042: enum = entries.elements();
043: }
044:
045:
046: public NamingContextEnumeration(Enumeration enum) {
047: this .enum = enum;
048: }
049:
050:
051: // -------------------------------------------------------------- Variables
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: NamingEntry entry = (NamingEntry) enum.nextElement();
096: return new NameClassPair(entry.name, entry.value.getClass().getName());
097: }
098:
099:
100:}
|