1 21 package net.mlw.vlh; 22 23 import java.util.ArrayList ; 24 import java.util.Iterator ; 25 import java.util.List ; 26 import java.util.NoSuchElementException ; 27 28 34 public class DefaultListBackedValueList implements ValueList 35 { 36 private List list = null; 37 private ValueListInfo info = null; 38 private Iterator iter = null; 39 40 42 public DefaultListBackedValueList() 43 { 44 this(new ArrayList (), new ValueListInfo()); 45 } 46 47 51 public DefaultListBackedValueList(List list) 52 { 53 this.list = list; 54 this.info = new ValueListInfo(); 55 if (list != null) 56 { 57 info.setTotalNumberOfEntries(list.size()); 58 } 59 60 } 61 62 67 public DefaultListBackedValueList(List list, ValueListInfo info) 68 { 69 this.list = list; 70 this.info = info; 71 } 72 73 75 public List getList() 76 { 77 return list; 78 } 79 80 82 public ValueListInfo getValueListInfo() 83 { 84 return info; 85 } 86 87 89 public boolean hasNext() 90 { 91 if (iter == null && list != null) 92 { 93 this.iter = list.iterator(); 94 } 95 96 return (iter == null) ? false : iter.hasNext(); 97 } 98 99 101 public Object next() throws NoSuchElementException 102 { 103 if (iter == null) 104 { 105 if (list != null) 106 { 107 this.iter = list.iterator(); 108 } 109 else 110 { 111 throw new NoSuchElementException (); 112 } 113 } 114 115 return iter.next(); 116 } 117 118 120 public void remove() 121 { 122 } 123 124 126 public void reset() 127 { 128 iter = null; 129 } 130 } 131 | Popular Tags |