KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > naming > NamingContextEnumeration


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * 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
19 package org.apache.naming;
20
21 import java.util.Iterator JavaDoc;
22
23 import javax.naming.NameClassPair JavaDoc;
24 import javax.naming.NamingEnumeration JavaDoc;
25 import javax.naming.NamingException JavaDoc;
26
27 /**
28  * Naming enumeration implementation.
29  *
30  * @author Remy Maucherat
31  * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
32  */

33
34 public class NamingContextEnumeration
35     implements NamingEnumeration JavaDoc {
36
37
38     // ----------------------------------------------------------- Constructors
39

40
41     public NamingContextEnumeration(Iterator JavaDoc entries) {
42         iterator = entries;
43     }
44
45
46     // -------------------------------------------------------------- Variables
47

48
49     /**
50      * Underlying enumeration.
51      */

52     protected Iterator JavaDoc iterator;
53
54
55     // --------------------------------------------------------- Public Methods
56

57
58     /**
59      * Retrieves the next element in the enumeration.
60      */

61     public Object JavaDoc next()
62         throws NamingException JavaDoc {
63         return nextElement();
64     }
65
66
67     /**
68      * Determines whether there are any more elements in the enumeration.
69      */

70     public boolean hasMore()
71         throws NamingException JavaDoc {
72         return iterator.hasNext();
73     }
74
75
76     /**
77      * Closes this enumeration.
78      */

79     public void close()
80         throws NamingException JavaDoc {
81     }
82
83
84     public boolean hasMoreElements() {
85         return iterator.hasNext();
86     }
87
88
89     public Object JavaDoc nextElement() {
90         NamingEntry entry = (NamingEntry) iterator.next();
91         return new NameClassPair JavaDoc(entry.name, entry.value.getClass().getName());
92     }
93
94
95 }
96
97
Popular Tags