com.vladsch.kotlin.jdbc.Rows.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-jdbc Show documentation
Show all versions of kotlin-jdbc Show documentation
A thin library that exposes JDBC API with the convenience of Kotlin and gets out of the way when not needed.
The newest version!
package com.vladsch.kotlin.jdbc
import java.sql.ResultSet
class Rows(rs: ResultSet) : Row(rs), Sequence {
private var movedNext = false
private class RowIterator(val row:Rows):Iterator {
override fun hasNext(): Boolean {
return row.hasNext()
}
override fun next(): Row {
return row.next();
}
}
override fun iterator(): Iterator {
return RowIterator(this);
}
fun hasNext(): Boolean {
if (rs.isClosed || (rs.type != ResultSet.TYPE_FORWARD_ONLY && (rs.isLast || rs.isAfterLast))) return false
if (movedNext) return true
movedNext = rs.next()
return movedNext
}
fun next(): Rows {
if (movedNext) {
movedNext = false
return this
}
rs.next()
return this;
}
}