java.lang.Object
uk.ac.manchester.spinnaker.alloc.db.Row

public final class Row
extends Object
A restricted form of result set. Note that this object must not be saved outside the context of iteration over its' query's results.
Author:
Donal Fellows
  • Method Details

    • getColumnNames

      public Set<String> getColumnNames()
      Get the column names from this row.
      Returns:
      The set of column names; all lookup of columns is by name, so the order is unimportant. (The set returned will iterate over the names in the order they are in the underlying result set, but this is considered "unimportant".)
      Throws:
      DataAccessException - If the column names can't be retrieved.
    • getString

      public String getString​(String columnLabel)
      Get the contents of the named column.
      Parameters:
      columnLabel - The name of the column.
      Returns:
      A string, or null on NULL.
      Throws:
      DataAccessException - If the column's contents can't be retrieved.
    • string

      public static DatabaseAPI.RowMapper<String> string​(String columnLabel)
      Get a function to get the contents of the named column.
      Parameters:
      columnLabel - The name of the column.
      Returns:
      A function to get the string from the column of a row.
    • getBoolean

      public boolean getBoolean​(String columnLabel)
      Get the contents of the named column.
      Parameters:
      columnLabel - The name of the column.
      Returns:
      A boolean, or false on NULL.
      Throws:
      DataAccessException - If the column's contents can't be retrieved.
    • bool

      public static DatabaseAPI.RowMapper<Boolean> bool​(String columnLabel)
      Get a function to get the contents of the named column.
      Parameters:
      columnLabel - The name of the column.
      Returns:
      A function to get the boolean from the column of a row.
    • getInt

      public int getInt​(String columnLabel)
      Get the contents of the named column.
      Parameters:
      columnLabel - The name of the column.
      Returns:
      An integer, or 0 on NULL.
      Throws:
      DataAccessException - If the column's contents can't be retrieved.
    • int32

      public static ToIntFunction<Row> int32​(String columnLabel)
      Get a function to get the contents of the named column.
      Parameters:
      columnLabel - The name of the column.
      Returns:
      A function to get the int from the column of a row.
    • getInteger

      public Integer getInteger​(String columnLabel)
      Get the contents of the named column.
      Parameters:
      columnLabel - The name of the column.
      Returns:
      An integer or null.
      Throws:
      DataAccessException - If the column's contents can't be retrieved.
    • integer

      public static DatabaseAPI.RowMapper<Integer> integer​(String columnLabel)
      Get a function to get the contents of the named column.
      Parameters:
      columnLabel - The name of the column.
      Returns:
      A function to get the nullable integer from the column of a row.
    • getBytes

      public byte[] getBytes​(String columnLabel)
      Get the contents of the named column.
      Parameters:
      columnLabel - The name of the column.
      Returns:
      A byte array, or null on NULL.
      Throws:
      DataAccessException - If the column's contents can't be retrieved.
    • bytes

      public static DatabaseAPI.RowMapper<byte[]> bytes​(String columnLabel)
      Get a function to get the contents of the named column.
      Parameters:
      columnLabel - The name of the column.
      Returns:
      A function to get the byte array from the column of a row.
    • getSerial

      public <T> T getSerial​(String columnLabel, Class<T> cls)
      Get the contents of the named column by deserialization.
      Type Parameters:
      T - The type of value expected.
      Parameters:
      columnLabel - The name of the column.
      cls - The type of value expected.
      Returns:
      A deserialized object, or null on NULL.
      Throws:
      DataAccessException - If the column's contents can't be retrieved.
      TypeMismatchDataAccessException - If the object is not of the required type.
    • serial

      public static <T> DatabaseAPI.RowMapper<T> serial​(String columnLabel, Class<T> cls)
      Get a function to get the contents of the named column.
      Type Parameters:
      T - The type of value expected.
      Parameters:
      columnLabel - The name of the column.
      cls - The type of value expected.
      Returns:
      A function to get the deserialized object from the column of a row.
    • getInstant

      public Instant getInstant​(String columnLabel)
      Get the contents of the named column.
      Parameters:
      columnLabel - The name of the column.
      Returns:
      An instant, or null on NULL.
      Throws:
      DataAccessException - If the column's contents can't be retrieved.
    • instant

      public static DatabaseAPI.RowMapper<Instant> instant​(String columnLabel)
      Get a function to get the contents of the named column.
      Parameters:
      columnLabel - The name of the column.
      Returns:
      A function to get the instant from the column of a row.
    • getDuration

      public Duration getDuration​(String columnLabel)
      Get the contents of the named column.
      Parameters:
      columnLabel - The name of the column.
      Returns:
      A duration, or null on NULL.
      Throws:
      DataAccessException - If the column's contents can't be retrieved.
    • duration

      public static DatabaseAPI.RowMapper<Duration> duration​(String columnLabel)
      Get a function to get the contents of the named column.
      Parameters:
      columnLabel - The name of the column.
      Returns:
      A function to get the duration from the column of a row.
    • getObject

      public Object getObject​(String columnLabel)
      Get the contents of the named column.
      Parameters:
      columnLabel - The name of the column.
      Returns:
      An automatically-decoded object, or null on NULL. (Only returns basic types due to the way SQLite type affinities work; Integer, Double, String, or byte[].)
      Throws:
      DataAccessException - If the column's contents can't be retrieved.
    • object

      public static DatabaseAPI.RowMapper<Object> object​(String columnLabel)
      Get a function to get the contents of the named column.
      Parameters:
      columnLabel - The name of the column.
      Returns:
      A function to get the object from the column of a row.
    • getEnum

      public <T extends Enum<T>> T getEnum​(String columnLabel, Class<T> type)
      Get the contents of the named column.
      Type Parameters:
      T - The enumeration type.
      Parameters:
      columnLabel - The name of the column.
      type - The enumeration type class.
      Returns:
      An enum value, or null on NULL.
      Throws:
      DataAccessException - If the column's contents can't be retrieved.
    • enumerate

      public static <T extends Enum<T>> DatabaseAPI.RowMapper<T> enumerate​(String columnLabel, Class<T> type)
      Get a function to get the contents of the named column.
      Type Parameters:
      T - The enumeration type.
      Parameters:
      columnLabel - The name of the column.
      type - The enumeration type class.
      Returns:
      A function to get the enum from the column of a row.
    • getLong

      public Long getLong​(String columnLabel)
      Get the contents of the named column.
      Parameters:
      columnLabel - The name of the column.
      Returns:
      A long value, or null on NULL.
      Throws:
      DataAccessException - If the column's contents can't be retrieved.
    • int64

      public static DatabaseAPI.RowMapper<Long> int64​(String columnLabel)
      Get a function to get the contents of the named column.
      Parameters:
      columnLabel - The name of the column.
      Returns:
      A function to get the nullable long from the column of a row.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getChip

      public ChipLocation getChip​(String x, String y)
      Get a chip from a result set row.
      Parameters:
      x - The name of the column with the X coordinate.
      y - The name of the column with the Y coordinate.
      Returns:
      The chip location.
    • chip

      public static DatabaseAPI.RowMapper<ChipLocation> chip​(String x, String y)
      Create a function for extracting a chip from a result set row.
      Parameters:
      x - The name of the column with the X coordinate.
      y - The name of the column with the Y coordinate.
      Returns:
      The mapping function.
    • getCore

      public CoreLocation getCore​(String x, String y, String p)
      Get a core from a result set row.
      Parameters:
      x - The name of the column with the X coordinate.
      y - The name of the column with the Y coordinate.
      p - The name of the column with the core ID.
      Returns:
      The core location.
    • core

      public static DatabaseAPI.RowMapper<CoreLocation> core​(String x, String y, String p)
      Create a function for extracting a core from a result set row.
      Parameters:
      x - The name of the column with the X coordinate.
      y - The name of the column with the Y coordinate.
      p - The name of the column with the core ID.
      Returns:
      The mapping function.
    • stream

      public static <T> MappableIterable<T> stream​(List<T> lst)
      Make a mappable iterator out of a list.
      Type Parameters:
      T - The type of the list.
      Parameters:
      lst - The list to convert.
      Returns:
      A mappable iterator.