1 25 26 27 package org.objectweb.easybeans.naming.context; 28 29 import java.util.Enumeration ; 30 import java.util.Hashtable ; 31 import java.util.NoSuchElementException ; 32 33 import javax.naming.NameClassPair ; 34 import javax.naming.NamingEnumeration ; 35 import javax.naming.NamingException ; 36 37 42 public class NamingEnumerationImpl implements NamingEnumeration <NameClassPair > { 43 44 47 private Enumeration names; 48 49 52 private Hashtable bindings; 53 54 58 NamingEnumerationImpl(final Hashtable bindings) { 59 this.bindings = bindings; 60 this.names = bindings.keys(); 61 } 62 63 70 public boolean hasMore() throws NamingException { 71 return names.hasMoreElements(); 72 } 73 74 84 public NameClassPair next() throws NamingException { 85 String name = (String ) names.nextElement(); 86 String className = bindings.get(name).getClass().getName(); 87 return new NameClassPair (name, className); 88 } 89 90 93 public void close() { 94 } 95 96 101 public NameClassPair nextElement() { 102 try { 103 return next(); 104 } catch (NamingException e) { 105 throw new NoSuchElementException (e.toString()); 106 } 107 } 108 109 115 public boolean hasMoreElements() { 116 try { 117 return hasMore(); 118 } catch (NamingException e) { 119 return false; 120 } 121 } 122 123 } 124 | Popular Tags |