01: /* JFox, the OpenSource J2EE Application Server
02: *
03: * Copyright (C) 2002 huihoo.com
04: * Distributable under GNU LGPL license
05: * See the GNU Lesser General Public License for more details.
06: */
07:
08: package org.huihoo.jfox.jndi;
09:
10: import javax.naming.NamingEnumeration;
11: import javax.naming.NamingException;
12: import java.util.Iterator;
13: import java.util.List;
14:
15: /**
16: *
17: * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
18: */
19:
20: public class NamingEnumerationImpl implements NamingEnumeration {
21: Iterator name_class_pair_iterator;
22:
23: public NamingEnumerationImpl(List list) {
24: name_class_pair_iterator = list.iterator();
25: }
26:
27: public Object next() throws NamingException {
28: try {
29: return name_class_pair_iterator.next();
30: } catch (Exception e) {
31: throw new NamingException(e.toString());
32: }
33: }
34:
35: public boolean hasMoreElements() {
36: // try{
37: // System.out.println("[NameEnumerationImpl] WARNING: Please use NameEnueration.hashMore() instead!");
38: return name_class_pair_iterator.hasNext();
39: // }catch(Exception e){
40: // e.printStackTrace();
41: // }
42: }
43:
44: public boolean hasMore() throws NamingException {
45: try {
46: return name_class_pair_iterator.hasNext();
47: } catch (Exception e) {
48: throw new NamingException(e.toString());
49: }
50: }
51:
52: public Object nextElement() {
53: // try{
54: // System.out.println("[NameEnumerationImpl] WARNING: Please use NameEnueration.next() instead!");
55: return name_class_pair_iterator.next();
56: // }catch(Exception e){
57: // e.printStackTrace();
58: // }
59: }
60:
61: public void close() throws NamingException {
62: try {
63: name_class_pair_iterator = null;
64: } catch (Exception e) {
65: throw new NamingException(e.toString());
66: }
67: }
68: }
|