Class Row

java.lang.Object
org.litebridge.db.spi.Row

public final class Row extends Object
A row of data returned from a database query.

Represents a row within a dataset, containing a collection of RowColumn objects. Each column in the row can be accessed either by its index or by its label/alias.

  • Constructor Details

  • Method Details

    • columns

      public List<RowColumn> columns()
      Returns the list of columns in this row.
      Returns:
      The list of row columns
    • columnMap

      public Map<String,RowColumn> columnMap()
      Provides a map of column labels to RowColumn objects for the current row.

      The underlying map implementation is a LinkedHashMap, preserving the order of columns.

      If the underlying map is not already initialised, it will be created and populated with the columns in this row; subsequent calls will return the same map.

      Returns:
      A map where the keys are column labels (strings) and the values are the corresponding RowColumn objects.
    • value

      public @Nullable Object value(int index)
      Retrieves the value of the column at the given index.
      Parameters:
      index - The row column index
      Returns:
      The row column value
      Throws:
      IndexOutOfBoundsException - if an invalid column index is specified
    • value

      public @Nullable Object value(String label)
      Retrieves the value of the column with the given label/alias.
      Parameters:
      label - The row column label (column name or alias)
      Returns:
      The row column value
      Throws:
      NoSuchElementException - if the column is not found
    • column

      public RowColumn column(int index) throws IndexOutOfBoundsException
      Retrieves the column at the given index.
      Parameters:
      index - The row column index
      Returns:
      The row column
      Throws:
      IndexOutOfBoundsException - if an invalid column index is specified
    • column

      public RowColumn column(String label) throws NoSuchElementException
      Retrieves the column with the given label/alias.
      Parameters:
      label - The row column label (column name or alias)
      Returns:
      The row column
      Throws:
      NoSuchElementException - if the column is not found
    • indexOf

      public int indexOf(Column column)
      Retrieves the index of a column from the row by its Column metadata.
      Parameters:
      column - the column metadata to match
      Returns:
      the index of the column if found, or -1 otherwise
    • indexOf

      public int indexOf(String label)
      Retrieves the index of a column from the row by its name.
      Parameters:
      label - the label of the column to retrieve
      Returns:
      the index of the column if found, or -1 otherwise
    • size

      public int size()
      Returns the number of columns in this row.
      Returns:
      The number of columns
    • structureHashCode

      public int structureHashCode()
      Computes or returns the cached structural hash code of this row.

      The structural hash code is based solely on the structure of the columns (labels, aliases, column metadata), ignoring row data values.

      Returns:
      the structural hash code of this row
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object