KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > util > mock > 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.util.mock;
23
24 import java.util.Arrays JavaDoc;
25 import java.util.Enumeration JavaDoc;
26 import java.util.Iterator JavaDoc;
27
28 import javax.naming.NamingEnumeration JavaDoc;
29 import javax.naming.NamingException JavaDoc;
30
31 /**
32  * NamingEnumeration implementation
33  *
34  * @author ddesjardins - eBMWebsourcing
35  */

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

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

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

58     public boolean hasMore() throws NamingException JavaDoc {
59         return iterator.hasNext();
60     }
61
62     /**
63      * @see Enumeration#hasMore()
64      */

65     public boolean hasMoreElements() {
66         return iterator.hasNext();
67     }
68
69     /**
70      * @see NamingEnumeration#next()
71      */

72     public T next() throws NamingException JavaDoc {
73         return iterator.next();
74     }
75
76     /**
77      * @see Enumeration#nextElement()
78      */

79     public T nextElement() {
80         return iterator.next();
81     }
82
83 }
84
Popular Tags