Package adams.data.spreadsheet
Class FindCellsIterator
- java.lang.Object
-
- adams.data.spreadsheet.FindCellsIterator
-
- All Implemented Interfaces:
Stoppable,StoppableWithFeedback,Iterator<Cell>
public class FindCellsIterator extends Object implements Iterator<Cell>, StoppableWithFeedback
Locates cells that match a certain string.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description protected intm_Columnthe current column index.protected Cellm_Nextthe next cell.protected FindCellsParametersm_Parametersthe search parameters.protected intm_Rowthe current row index.protected SpreadSheetm_SpreadSheetthe spreadsheet to search.protected booleanm_Stoppedwhether the search was stopped.
-
Constructor Summary
Constructors Constructor Description FindCellsIterator(SpreadSheet spreadSheet, FindCellsParameters parameters)Initializes the iterator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FindCellsParametersgetParameters()Returns the search string.SpreadSheetgetSpreadSheet()Returns the spreadsheet that is being searched.booleanhasNext()Returnstrueif the iteration has more elements.protected booleanisMatch(Cell cell)Checks whether the cell is matching the criteria.booleanisStopped()Whether the execution has been stopped.Cellnext()Returns the next element in the iteration.protected CellnextCell()Moves to the next cell.voidstopExecution()Stops the execution.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
-
-
-
Field Detail
-
m_SpreadSheet
protected SpreadSheet m_SpreadSheet
the spreadsheet to search.
-
m_Parameters
protected FindCellsParameters m_Parameters
the search parameters.
-
m_Row
protected int m_Row
the current row index.
-
m_Column
protected int m_Column
the current column index.
-
m_Next
protected Cell m_Next
the next cell.
-
m_Stopped
protected boolean m_Stopped
whether the search was stopped.
-
-
Constructor Detail
-
FindCellsIterator
public FindCellsIterator(SpreadSheet spreadSheet, FindCellsParameters parameters)
Initializes the iterator.- Parameters:
spreadSheet- the spreadsheet to searchparameters- the search parameters
-
-
Method Detail
-
getSpreadSheet
public SpreadSheet getSpreadSheet()
Returns the spreadsheet that is being searched.- Returns:
- the spreadsheet
-
getParameters
public FindCellsParameters getParameters()
Returns the search string.- Returns:
- the search string
-
nextCell
protected Cell nextCell()
Moves to the next cell.- Returns:
- the next cell to inspect, null if no more cells
-
isMatch
protected boolean isMatch(Cell cell)
Checks whether the cell is matching the criteria.- Parameters:
cell- the cell to check- Returns:
- true if a match
-
hasNext
public boolean hasNext()
Returnstrueif the iteration has more elements. (In other words, returnstrueifnext()would return an element rather than throwing an exception.)
-
next
public Cell next()
Returns the next element in the iteration.- Specified by:
nextin interfaceIterator<Cell>- Returns:
- the next element in the iteration
- Throws:
NoSuchElementException- if the iteration has no more elements
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecutionin interfaceStoppable
-
isStopped
public boolean isStopped()
Whether the execution has been stopped.- Specified by:
isStoppedin interfaceStoppableWithFeedback- Returns:
- true if stopped
-
-