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;
19:
20: import java.util.Iterator;
21:
22: import javax.naming.NameClassPair;
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 NamingContextEnumeration implements NamingEnumeration {
34:
35: // ----------------------------------------------------------- Constructors
36:
37: public NamingContextEnumeration(Iterator entries) {
38: iterator = entries;
39: }
40:
41: // -------------------------------------------------------------- Variables
42:
43: /**
44: * Underlying enumeration.
45: */
46: protected Iterator iterator;
47:
48: // --------------------------------------------------------- Public Methods
49:
50: /**
51: * Retrieves the next element in the enumeration.
52: */
53: public Object next() throws NamingException {
54: return nextElement();
55: }
56:
57: /**
58: * Determines whether there are any more elements in the enumeration.
59: */
60: public boolean hasMore() throws NamingException {
61: return iterator.hasNext();
62: }
63:
64: /**
65: * Closes this enumeration.
66: */
67: public void close() throws NamingException {
68: }
69:
70: public boolean hasMoreElements() {
71: return iterator.hasNext();
72: }
73:
74: public Object nextElement() {
75: NamingEntry entry = (NamingEntry) iterator.next();
76: return new NameClassPair(entry.name, entry.value.getClass()
77: .getName());
78: }
79:
80: }
|