1 package org.tigris.scarab.util; 2 3 48 49 import java.util.Iterator ; 50 import java.util.NoSuchElementException ; 51 52 public interface IteratorWithSize extends Iterator 53 { 54 public static final IteratorWithSize EMPTY = new EmptyIteratorWithSize(); 55 56 public int size(); 57 } 58 59 class EmptyIteratorWithSize implements IteratorWithSize 60 { 61 public boolean hasNext() 62 { 63 return false; 64 } 65 66 public Object next() 67 { 68 throw new NoSuchElementException ("This is an empty list."); } 70 71 public void remove() 72 { 73 throw new IllegalStateException ("next() will throw exception, so it is " 74 + "not possible to call this method."); } 76 77 public int size() 78 { 79 return 0; 80 } 81 } 82 | Popular Tags |