KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > jbi > registry > mock > MockNamingEnumeration


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: MockNamingEnumeration.java 12:26:59 ddesjardins $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.jbi.registry.mock;
23
24 import java.util.ArrayList JavaDoc;
25 import java.util.List JavaDoc;
26
27 import javax.naming.NamingEnumeration JavaDoc;
28 import javax.naming.NamingException JavaDoc;
29
30 /**
31  * MockNamingEnumeration
32  *
33  * @author ddesjardins - eBMWebsourcing
34  */

35 public class MockNamingEnumeration<T> implements NamingEnumeration JavaDoc {
36
37     private List JavaDoc<T> elems = new ArrayList JavaDoc<T>();
38
39     private int pos = 0;
40
41     public Object JavaDoc next() throws NamingException JavaDoc {
42         return elems.get(pos++);
43     }
44
45     public boolean hasMore() throws NamingException JavaDoc {
46         return pos < elems.size();
47     }
48
49     public void close() throws NamingException JavaDoc {
50     }
51
52     public boolean hasMoreElements() {
53         return pos < elems.size();
54     }
55
56     public Object JavaDoc nextElement() {
57         return elems.get(pos++);
58     }
59
60     public List JavaDoc<T> getElems() {
61         return elems;
62     }
63
64     public void setElems(List JavaDoc<T> elems) {
65         this.elems = elems;
66     }
67
68     public int getPos() {
69         return pos;
70     }
71
72     public void setPos(int pos) {
73         this.pos = pos;
74     }
75
76 }
77
Popular Tags