KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > kernel > registry > jndi > NamingEnumerationImpl


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * -------------------------------------------------------------------------
19  * $Id: NamingEnumerationImpl.java 5:07:43 PM ddesjardins $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.kernel.registry.jndi;
23
24 import java.util.Arrays JavaDoc;
25 import java.util.Iterator JavaDoc;
26
27 import javax.naming.NamingEnumeration JavaDoc;
28 import javax.naming.NamingException JavaDoc;
29
30 /**
31  * NamingEnumeration implementation
32  *
33  * @author ddesjardins - eBMWebsourcing
34  */

35 public class NamingEnumerationImpl<T> implements NamingEnumeration JavaDoc<T> {
36
37     /**
38      * Iterator
39      */

40     protected Iterator JavaDoc<T> iterator;
41
42     public NamingEnumerationImpl(T[] array) {
43         super();
44         iterator = Arrays.asList(array).iterator();
45     }
46
47     /**
48      * @see NamingEnumeration#close()
49      */

50     public void close() throws NamingException JavaDoc {
51         iterator = null;
52     }
53
54     /**
55      * @see NamingEnumeration#hasMore()
56      */

57     public boolean hasMore() throws NamingException JavaDoc {
58         return iterator.hasNext();
59     }
60
61     public boolean hasMoreElements() {
62         return iterator.hasNext();
63     }
64
65     /**
66      * @see NamingEnumeration#next()
67      */

68     public T next() throws NamingException JavaDoc {
69         return iterator.next();
70     }
71
72     public T nextElement() {
73         return iterator.next();
74     }
75
76 }
77
Popular Tags