1 55 package org.lateralnz.panther.naming; 56 57 import java.util.Iterator ; 58 import java.util.HashMap ; 59 import java.util.NoSuchElementException ; 60 import javax.naming.*; 61 62 import org.lateralnz.common.util.FilteredIterator; 63 64 68 public class LocalContextNamingEnumeration implements NamingEnumeration { 69 70 private HashMap clone; 71 private Iterator iter = null; 72 73 public LocalContextNamingEnumeration() { 74 } 75 76 public LocalContextNamingEnumeration(LocalContext ctx) { 77 clone = (HashMap )ctx.objects.clone(); 78 iter = clone.keySet().iterator(); 79 } 80 81 public void close() throws javax.naming.NamingException { 82 iter = null; 83 } 84 85 public boolean hasMore() throws javax.naming.NamingException { 86 return hasMoreElements(); 87 } 88 89 public boolean hasMoreElements() { 90 if (iter != null) { 91 return iter.hasNext(); 92 } 93 else { 94 return false; 95 } 96 } 97 98 public Object next() throws javax.naming.NamingException { 99 return nextElement(); 100 } 101 102 public Object nextElement() { 103 if (iter != null) { 104 String key = (String )iter.next(); 105 return clone.get(key); 106 } 107 else { 108 throw new NoSuchElementException (); 109 } 110 } 111 112 } | Popular Tags |