1 15 package org.apache.tapestry.contrib.table.model.common; 16 17 import java.util.Iterator ; 18 import java.util.NoSuchElementException ; 19 20 23 public class ArrayIterator implements Iterator 24 { 25 private Object [] m_arrValues; 26 private int m_nFrom; 27 private int m_nTo; 28 private int m_nCurrent; 29 30 public ArrayIterator(Object [] arrValues) 31 { 32 this(arrValues, 0, arrValues.length); 33 } 34 35 public ArrayIterator(Object [] arrValues, int nFrom, int nTo) 36 { 37 m_arrValues = arrValues; 38 m_nFrom = nFrom; 39 m_nTo = nTo; 40 41 if (m_nFrom < 0) 42 m_nFrom = 0; 43 if (m_nTo < m_nFrom) 44 m_nTo = m_nFrom; 45 if (m_nTo > m_arrValues.length) 46 m_nTo = m_arrValues.length; 47 48 m_nCurrent = m_nFrom; 49 } 50 51 54 public boolean hasNext() 55 { 56 return m_nCurrent < m_nTo; 57 } 58 59 62 public Object next() 63 { 64 if (!hasNext()) 66 throw new NoSuchElementException (); 67 return m_arrValues[m_nCurrent++]; 68 } 69 70 73 public void remove() 74 { 75 throw new UnsupportedOperationException (); 76 } 77 78 } 79 | Popular Tags |