1 16 package org.apache.commons.collections.iterators; 17 18 import java.util.NoSuchElementException ; 19 20 28 abstract class AbstractEmptyIterator { 29 30 33 protected AbstractEmptyIterator() { 34 super(); 35 } 36 37 public boolean hasNext() { 38 return false; 39 } 40 41 public Object next() { 42 throw new NoSuchElementException ("Iterator contains no elements"); 43 } 44 45 public boolean hasPrevious() { 46 return false; 47 } 48 49 public Object previous() { 50 throw new NoSuchElementException ("Iterator contains no elements"); 51 } 52 53 public int nextIndex() { 54 return 0; 55 } 56 57 public int previousIndex() { 58 return -1; 59 } 60 61 public void add(Object obj) { 62 throw new UnsupportedOperationException ("add() not supported for empty Iterator"); 63 } 64 65 public void set(Object obj) { 66 throw new IllegalStateException ("Iterator contains no elements"); 67 } 68 69 public void remove() { 70 throw new IllegalStateException ("Iterator contains no elements"); 71 } 72 73 public Object getKey() { 74 throw new IllegalStateException ("Iterator contains no elements"); 75 } 76 77 public Object getValue() { 78 throw new IllegalStateException ("Iterator contains no elements"); 79 } 80 81 public Object setValue(Object value) { 82 throw new IllegalStateException ("Iterator contains no elements"); 83 } 84 85 public void reset() { 86 } 88 89 } 90 | Popular Tags |