All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vladsch.kotlin.jdbc.Rows.kt Maven / Gradle / Ivy

Go to download

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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy