1 16 package com.blandware.atleap.webapp.util.core; 17 18 import java.util.*; 19 20 33 public class Enumerator implements Enumeration { 34 35 36 38 39 44 public Enumerator(Collection collection) { 45 46 this(collection.iterator()); 47 48 } 49 50 51 57 public Enumerator(Collection collection, boolean clone) { 58 59 this(collection.iterator(), clone); 60 61 } 62 63 64 70 public Enumerator(Iterator iterator) { 71 72 super(); 73 this.iterator = iterator; 74 75 } 76 77 78 85 public Enumerator(Iterator iterator, boolean clone) { 86 87 super(); 88 if (!clone) { 89 this.iterator = iterator; 90 } else { 91 List list = new ArrayList(); 92 while (iterator.hasNext()) { 93 list.add(iterator.next()); 94 } 95 this.iterator = list.iterator(); 96 } 97 98 } 99 100 101 106 public Enumerator(Map map) { 107 108 this(map.values().iterator()); 109 110 } 111 112 113 119 public Enumerator(Map map, boolean clone) { 120 121 this(map.values().iterator(), clone); 122 123 } 124 125 126 128 129 133 private Iterator iterator = null; 134 135 136 138 139 146 public boolean hasMoreElements() { 147 148 return (iterator.hasNext()); 149 150 } 151 152 153 161 public Object nextElement() throws NoSuchElementException { 162 163 return (iterator.next()); 164 165 } 166 167 } 168 | Popular Tags |