1 11 package org.jboss.portlet.forums.helper; 12 13 import java.util.Iterator ; 14 15 21 public class IndexIterator 22 implements Iterator 23 { 24 private int index; 25 private Iterator iterator; 26 27 32 public IndexIterator(Iterator iterator) 33 { 34 this(iterator, 0); 35 } 36 37 43 public IndexIterator(Iterator iterator, 44 int start) 45 { 46 this.iterator = iterator; 47 this.index = start; 48 } 49 50 55 public boolean hasNext() 56 { 57 return iterator.hasNext(); 58 } 59 60 65 public Object next() 66 { 67 index++; 68 return iterator.next(); 69 } 70 71 74 public void remove() 75 { 76 iterator.remove(); 77 } 78 79 84 public int getIndex() 85 { 86 return index; 87 } 88 89 96 public static IndexIterator wrap(Iterator iterator) 97 { 98 return new IndexIterator(iterator); 99 } 100 101 109 public static IndexIterator wrap(Iterator iterator, 110 int start) 111 { 112 return new IndexIterator(iterator, start); 113 } 114 } | Popular Tags |