Package adams.db
Class SpectrumIterator
- java.lang.Object
-
- adams.db.SpectrumIterator
-
- All Implemented Interfaces:
AutoCloseable,Iterator<Spectrum>
public class SpectrumIterator extends Object implements Iterator<Spectrum>, AutoCloseable
Iterator for Spectrum result sets.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description protected Connectionm_Connectionthe connection to close.protected Spectrumm_Nextthe next spectrum.protected ResultSetm_ResultSetthe underlying resultset.protected SampleDataIntfm_SampleDatathe underlying sampledata DB handler.protected intm_Sizethe number of rows in the resultset.protected SpectrumIntfm_Spectrumthe underlying spectrum DB handler.
-
Constructor Summary
Constructors Constructor Description SpectrumIterator(SpectrumIntf spectrum, SampleDataIntf sampleData, ResultSet resultSet, Connection connection)Initializes the iterator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the results set and query.intgetSize()Returns the number of rows.booleanhasNext()Returnstrueif the iteration has more elements.Spectrumnext()Returns the next element in the iteration.-
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_Spectrum
protected SpectrumIntf m_Spectrum
the underlying spectrum DB handler.
-
m_SampleData
protected SampleDataIntf m_SampleData
the underlying sampledata DB handler.
-
m_ResultSet
protected ResultSet m_ResultSet
the underlying resultset.
-
m_Next
protected Spectrum m_Next
the next spectrum.
-
m_Connection
protected Connection m_Connection
the connection to close.
-
m_Size
protected int m_Size
the number of rows in the resultset.
-
-
Constructor Detail
-
SpectrumIterator
public SpectrumIterator(SpectrumIntf spectrum, SampleDataIntf sampleData, ResultSet resultSet, Connection connection)
Initializes the iterator.- Parameters:
spectrum- the spectrum handlersampleData- the sampledata handlerresultSet- the result set to iterateconnection- the connection to close after finished reading, if any
-
-
Method Detail
-
getSize
public int getSize()
Returns the number of rows.- Returns:
- the rows
-
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 Spectrum next()
Returns the next element in the iteration.- Specified by:
nextin interfaceIterator<Spectrum>- Returns:
- the next element in the iteration
- Throws:
NoSuchElementException- if the iteration has no more elements
-
close
public void close() throws ExceptionCloses the results set and query.- Specified by:
closein interfaceAutoCloseable- Throws:
Exception- does not happen
-
-