zinger.bsheet
Class RangeIterator

java.lang.Object
  extended by zinger.bsheet.RangeIterator
All Implemented Interfaces:
java.util.Iterator

public class RangeIterator
extends java.lang.Object
implements java.util.Iterator

Iterates through cell addresses of a specified rectangle.

Author:
Alexey Zinger (inline_four@yahoo.com)
See Also:
next()

Field Summary
protected  int bottomRow
           
protected  int col
           
protected  int leftCol
           
protected  int rightCol
           
protected  int row
           
protected  int topRow
           
 
Constructor Summary
RangeIterator(int leftCol, int topRow, int rightCol, int bottomRow)
          Constructs an instance ready for iteration of the range specified by its top left and bottom right corners.
 
Method Summary
 boolean hasNext()
           
 java.lang.Object next()
          Advances through the specified rectangular range.
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

leftCol

protected final int leftCol

topRow

protected final int topRow

rightCol

protected final int rightCol

bottomRow

protected final int bottomRow

col

protected int col

row

protected int row
Constructor Detail

RangeIterator

public RangeIterator(int leftCol,
                     int topRow,
                     int rightCol,
                     int bottomRow)
Constructs an instance ready for iteration of the range specified by its top left and bottom right corners.

Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator

next

public java.lang.Object next()
                      throws java.util.NoSuchElementException
Advances through the specified rectangular range. Advancements are made left to right and top to bottom.

Specified by:
next in interface java.util.Iterator
Returns:
a Point, whose x property represents a model column index and y property represents a row index
Throws:
java.util.NoSuchElementException - if the end of the range (bottom right corner) has already been reached prior to the call

remove

public void remove()
            throws java.lang.UnsupportedOperationException
Specified by:
remove in interface java.util.Iterator
Throws:
java.lang.UnsupportedOperationException - always