Class SQLHelper.Results

java.lang.Object
redempt.redlib.sql.SQLHelper.Results
All Implemented Interfaces:
AutoCloseable
Enclosing class:
SQLHelper

public static class SQLHelper.Results extends Object implements AutoCloseable
Wraps a ResultSet with easier use
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the wrapped ResultSet.
    void
    Performs an operation on every row in these Results, passing itself each time it iterates to a new row
    <T> T
    get(int column)
    Gets an Object in the given column in the current row
    byte[]
    getBytes(int column)
    Gets the bytes in the given column in the current row
    int
    Gets the column count from the returned data
    getLong(int column)
    Gets a Long in the given column in the current row
    getString(int column)
    Gets a String in the given column in the current row
    boolean
     
    boolean
    Moves to the next row in the wrapped ResultSet.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Returns:
      False if the first call of ResultSet.next() on the wrapped ResultSet returned false, true otherwise
    • next

      public boolean next()
      Moves to the next row in the wrapped ResultSet. Note that this method is called immediately when the Results object is constructed, and does not need to be called to retrieve the items in the first row.
      Returns:
      True if there is another row available in the wrapped ResultSet
    • forEach

      public void forEach(Consumer<SQLHelper.Results> lambda)
      Performs an operation on every row in these Results, passing itself each time it iterates to a new row
      Parameters:
      lambda - The callback to be run on every row in these Results
    • get

      public <T> T get(int column)
      Gets an Object in the given column in the current row
      Type Parameters:
      T - The type to cast the return value to
      Parameters:
      column - The index of the column to get, starting at 1
      Returns:
      The value in the column
    • getBytes

      public byte[] getBytes(int column)
      Gets the bytes in the given column in the current row
      Parameters:
      column - The index of the column to get, starting at 1
      Returns:
      The bytes in the column
    • getString

      public String getString(int column)
      Gets a String in the given column in the current row
      Parameters:
      column - The index of the column to get, starting at 1
      Returns:
      The String in the column Note: This method exists because ResultSet.getObject(int) can return an Integer if the String in the column can be parsed into one.
    • getLong

      public Long getLong(int column)
      Gets a Long in the given column in the current row
      Parameters:
      column - The index of the column to get, starting at 1
      Returns:
      The String in the column Note: This method exists because ResultSet.getObject(int) can return an Integer if the Long in the column can be parsed into one.
    • getColumnCount

      public int getColumnCount()
      Gets the column count from the returned data
      Returns:
      The column count
    • close

      public void close()
      Closes the wrapped ResultSet. Call this when you are done using these Results.
      Specified by:
      close in interface AutoCloseable