1 2 12 package com.versant.core.jdo; 13 14 import java.util.ListIterator ; 15 16 import com.versant.core.common.BindingSupportImpl; 17 18 public class IteratorWrapper implements JDOListIterator { 19 private ListIterator iterator; 20 private boolean closed; 21 22 public IteratorWrapper(ListIterator iterator) { 23 this.iterator = iterator; 24 } 25 26 public boolean hasNext() { 27 if (closed) return false; 28 return iterator.hasNext(); 29 } 30 31 public Object next() { 32 if (closed) { 33 throw BindingSupportImpl.getInstance().noSuchElement(""); 34 } 35 return iterator.next(); 36 } 37 38 public void remove() { 39 throw BindingSupportImpl.getInstance().unsupportedOperation(""); 40 } 41 42 public void add(Object o) { 43 throw BindingSupportImpl.getInstance().unsupportedOperation(""); 44 } 45 46 public void set(Object o) { 47 throw BindingSupportImpl.getInstance().unsupportedOperation(""); 48 } 49 50 public int previousIndex() { 51 if (closed) { 52 throw BindingSupportImpl.getInstance().noSuchElement(""); 53 } 54 return iterator.previousIndex(); 55 } 56 57 public int nextIndex() { 58 if (closed) { 59 throw BindingSupportImpl.getInstance().noSuchElement(""); 60 } 61 return iterator.nextIndex(); 62 } 63 64 public Object previous() { 65 if (closed) { 66 throw BindingSupportImpl.getInstance().noSuchElement(""); 67 } 68 return iterator.previous(); 69 } 70 71 public boolean hasPrevious() { 72 if (closed) return false; 73 return iterator.hasPrevious(); 74 } 75 76 public void close() { 77 this.closed = true; 78 iterator = null; 79 } 80 } 81 | Popular Tags |