Class Row

java.lang.Object
tech.tablesaw.api.Row
All Implemented Interfaces:
Iterator<Row>

public class Row extends Object implements Iterator<Row>
Represents a row in a Relation (either a Table or TableSlice), allowing iteration over the relation. During iteration, the Row slides over the table row-wise, exposing data as it advances, acting as a cursor into the table. There is only one Row object for the entire table during iteration.

Implementation Note: The row is always implemented over a TableSlice. If the constructor argument is a table, it is wrapped by a slice over the whole table.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Row(Table table)
    Constructs a Row object for the given table
    Row(Table table, int rowNumber)
    Constructs a Row object for the given Table, with the Row positioned at the given 0-based index
    Row(TableSlice tableSlice)
    Constructs a Row object for the given TableSlice
    Row(TableSlice tableSlice, int rowNumber)
    Constructs a Row object for the given TableSlice, with the Row positioned at the given 0-based index
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    at(int rowNumber)
    Moves this Row to the given 0-based row index
    int
    Returns the number of columns in this Row
    Returns a list containing the names of each column in the row
    getBoolean(int columnIndex)
    Returns a Boolean value from this Row at the given column index.
    getBoolean(String columnName)
    Returns a Boolean value from this Row at the column of the given name.
    byte
    getBooleanAsByte(int columnIndex)
    Returns an element from a Boolean column in its internal byte form, avoiding boxing
    byte
    Returns an element from a Boolean column in its internal byte form, avoiding boxing
    getColumnType(int columnIndex)
     
    getColumnType(String columnName)
    Returns the type of the named column
    getDate(int columnIndex)
    Returns a LocalDate value from this Row at the column with the given index.
    getDate(String columnName)
    Returns a LocalDate value from this Row at the column of the given name.
    getDateTime(int columnIndex)
    Returns a LocalDateTime from this Row at the column with the given index.
    getDateTime(String columnName)
    Returns a LocalDateTime value from this Row at the column of the given name.
    double
    getDouble(int columnIndex)
    Returns a double from this Row at the column with the given index.
    double
    getDouble(String columnName)
    Returns a double from this Row at the column of the given name.
    float
    getFloat(int columnIndex)
    Returns a float from this Row at the column with the given index.
    float
    getFloat(String columnName)
    Returns a float from this Row at the column of the given name.
    getInstant(int columnIndex)
    Returns an Instant from this Row at the column with the given index.
    getInstant(String columnName)
    Returns an Instant value from this Row at the column of the given name.
    int
    getInt(int columnIndex)
    Returns an int from this Row at the column with the given index.
    int
    getInt(String columnName)
    Returns an int from this Row at the column of the given name.
    long
    getLong(int columnIndex)
    Returns a long from this Row at the column with the given index.
    long
    getLong(String columnName)
    Returns a long from this Row at the column of the given name.
    double
    getNumber(String columnName)
    Returns a double representing the value held in the column with the given name at this row, for any numeric column type
    getObject(int columnIndex)
    Returns an Object representing the LocalTime from this Row at the column with the given index.
    getObject(String columnName)
    Returns an Object representing the value from this Row at the column of the given name.
    int
    getPackedDate(int columnIndex)
    Returns an int representing the LocalTime from this Row at the column with the given index.
    int
    getPackedDate(String columnName)
    Returns an int representing the LocalDate from this Row at the column of the given name.
    long
    getPackedDateTime(int columnIndex)
    Returns an long representing the LocalTime from this Row at the column with the given index.
    long
    Returns a long representing the LocalDateTime from this Row at the column of the given name.
    long
    getPackedInstant(int columnIndex)
    Returns an long representing the LocalTime from this Row at the column with the given index.
    long
    Returns a long representing the Instant from this Row at the column of the given name.
    int
    getPackedTime(int columnIndex)
    Returns an int representing the LocalTime from this Row at the column with the given index.
    int
    getPackedTime(String columnName)
    Returns an int representing the LocalTime from this Row at the column of the given name.
    int
    Returns the zero-based index of the current position of this Row
    short
    getShort(int columnIndex)
    Returns a short value from this Row at the column with the given index.
    short
    getShort(String columnName)
    Returns a short from this Row at the column of the given name.
    getString(int columnIndex)
    Returns a String value from this Row at the column with the given index.
    getString(String columnName)
    Returns a String from this Row at the column of the given name.
    getText(int columnIndex)
    Returns a String value from this Row at the column with the given index.
    getText(String columnName)
    Returns a String representing the text from this Row at the column of the given name.
    getTime(int columnIndex)
    Returns a LocalTime value from this Row at the column with the given index.
    getTime(String columnName)
    Returns a LocalTime value from this Row at the column of the given name.
    boolean
    Returns true if there's at least one more row beyond the current one.
    boolean
    isMissing(String columnName)
    Returns true if the value at columnName is missing, and false otherwise
    Increments the row pointer, making the next row's data accessible
    int
    Returns a hash computed on the values in the backing table at this row
    void
    setBoolean(int columnIndex, boolean value)
    Sets the value of the column at the given index and this Row to the given value.
    void
    setBoolean(String columnName, boolean value)
    Sets the value of the column with the given name at this Row to the given value.
    void
    setDate(int columnIndex, LocalDate value)
    Sets the value of the column at the given index and this Row to the given value.
    void
    setDate(String columnName, LocalDate value)
    Sets the value of the column with the given name at this Row to the given value.
    void
    setDateTime(int columnIndex, LocalDateTime value)
    Sets the value of the column at the given index and this Row to the given value.
    void
    setDateTime(String columnName, LocalDateTime value)
    Sets the value of the column with the given name at this Row to the given value.
    void
    setDouble(int columnIndex, double value)
    Sets the value of the column at the given index and this Row to the given value.
    void
    setDouble(String columnName, double value)
    Sets the value of the column with the given name at this Row to the given value.
    void
    setFloat(int columnIndex, float value)
    Sets the value of the column at the given index and this Row to the given value.
    void
    setFloat(String columnName, float value)
    Sets the value of the column with the given name at this Row to the given value.
    void
    setInstant(int columnIndex, Instant value)
    Sets the value of the column at the given index and this Row to the given value.
    void
    setInstant(String columnName, Instant value)
    Sets the value of the column with the given name at this Row to the given value.
    void
    setInt(int columnIndex, int value)
    Sets the value of the column at the given index and this Row to the given value.
    void
    setInt(String columnName, int value)
    Sets the value of the column with the given name at this Row to the given value.
    void
    setLong(int columnIndex, long value)
    Sets the value of the column at the given index and this Row to the given value.
    void
    setLong(String columnName, long value)
    Sets the value of the column with the given name at this Row to the given value.
    void
    setMissing(int columnIndex)
    Sets the value of the given column at this Row to the appropriate missing-value indicator for the column type.
    void
    setMissing(String columnName)
    Sets the value of the given column at this Row to the appropriate missing-value indicator for the column type.
    void
    setShort(int columnIndex, short value)
    Sets the value of the column at the given index and this Row to the given value.
    void
    setShort(String columnName, short value)
    Sets the value of the column with the given name at this Row to the given value.
    void
    setString(int columnIndex, String value)
    Sets the value of the column at the given index and this Row to the given value.
    void
    setString(String columnName, String value)
    Sets the value of the column with the given name at this Row to the given value.
    void
    setText(int columnIndex, String value)
    Sets the value of the column at the given index and this Row to the given value.
    void
    setText(String columnName, String value)
    Sets the value of the column with the given name at this Row to the given value.
    void
    setTime(int columnIndex, LocalTime value)
    Sets the value of the column at the given index and this Row to the given value.
    void
    setTime(String columnName, LocalTime value)
    Sets the value of the column with the given name at this Row to the given value.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.util.Iterator

    forEachRemaining, remove
  • Constructor Details

    • Row

      public Row(Table table)
      Constructs a Row object for the given table
    • Row

      public Row(TableSlice tableSlice)
      Constructs a Row object for the given TableSlice
    • Row

      public Row(Table table, int rowNumber)
      Constructs a Row object for the given Table, with the Row positioned at the given 0-based index
    • Row

      public Row(TableSlice tableSlice, int rowNumber)
      Constructs a Row object for the given TableSlice, with the Row positioned at the given 0-based index
  • Method Details

    • at

      public void at(int rowNumber)
      Moves this Row to the given 0-based row index
    • columnCount

      public int columnCount()
      Returns the number of columns in this Row
    • columnNames

      public List<String> columnNames()
      Returns a list containing the names of each column in the row
    • getBoolean

      public Boolean getBoolean(int columnIndex)
      Returns a Boolean value from this Row at the given column index.
    • getBooleanAsByte

      public byte getBooleanAsByte(int columnIndex)
      Returns an element from a Boolean column in its internal byte form, avoiding boxing
    • getBooleanAsByte

      public byte getBooleanAsByte(String columnName)
      Returns an element from a Boolean column in its internal byte form, avoiding boxing
    • getBoolean

      public Boolean getBoolean(String columnName)
      Returns a Boolean value from this Row at the column of the given name. An IllegalStateException is thrown if the column is not present in the Row and an * IllegalArgumentException is thrown if the column has a different type
    • getDate

      public LocalDate getDate(String columnName)
      Returns a LocalDate value from this Row at the column of the given name. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if the column has a different type
    • getDate

      public LocalDate getDate(int columnIndex)
      Returns a LocalDate value from this Row at the column with the given index. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if the column has a different type
    • getDateTime

      public LocalDateTime getDateTime(int columnIndex)
      Returns a LocalDateTime from this Row at the column with the given index. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type
    • getDateTime

      public LocalDateTime getDateTime(String columnName)
      Returns a LocalDateTime value from this Row at the column of the given name. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type
    • getInstant

      public Instant getInstant(int columnIndex)
      Returns an Instant from this Row at the column with the given index. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type
    • getInstant

      public Instant getInstant(String columnName)
      Returns an Instant value from this Row at the column of the given name. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type
    • getDouble

      public double getDouble(int columnIndex)
      Returns a double from this Row at the column with the given index. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type
    • getDouble

      public double getDouble(String columnName)
      Returns a double from this Row at the column of the given name. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type
    • getFloat

      public float getFloat(int columnIndex)
      Returns a float from this Row at the column with the given index. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type
    • getFloat

      public float getFloat(String columnName)
      Returns a float from this Row at the column of the given name. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type
    • getInt

      public int getInt(int columnIndex)
      Returns an int from this Row at the column with the given index. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type
    • getInt

      public int getInt(String columnName)
      Returns an int from this Row at the column of the given name. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type
    • getLong

      public long getLong(int columnIndex)
      Returns a long from this Row at the column with the given index. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type
    • getLong

      public long getLong(String columnName)
      Returns a long from this Row at the column of the given name. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type
    • getObject

      public Object getObject(String columnName)
      Returns an Object representing the value from this Row at the column of the given name. An IllegalStateException is thrown if the column is not present in the Row.
    • getObject

      public Object getObject(int columnIndex)
      Returns an Object representing the LocalTime from this Row at the column with the given index. An IllegalStateException is thrown if the column is not present in the Row
    • getPackedDate

      public int getPackedDate(String columnName)
      Returns an int representing the LocalDate from this Row at the column of the given name. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type
    • getPackedDate

      public int getPackedDate(int columnIndex)
      Returns an int representing the LocalTime from this Row at the column with the given index. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type type
    • getPackedInstant

      public long getPackedInstant(int columnIndex)
      Returns an long representing the LocalTime from this Row at the column with the given index. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type type
    • getPackedInstant

      public long getPackedInstant(String columnName)
      Returns a long representing the Instant from this Row at the column of the given name. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type
    • getPackedDateTime

      public long getPackedDateTime(String columnName)
      Returns a long representing the LocalDateTime from this Row at the column of the given name. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type
    • getPackedDateTime

      public long getPackedDateTime(int columnIndex)
      Returns an long representing the LocalTime from this Row at the column with the given index. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type type
    • getPackedTime

      public int getPackedTime(String columnName)
      Returns an int representing the LocalTime from this Row at the column of the given name. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type
    • getPackedTime

      public int getPackedTime(int columnIndex)
      Returns an int representing the LocalTime from this Row at the column with the given index. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type type
    • getShort

      public short getShort(int columnIndex)
      Returns a short value from this Row at the column with the given index. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type type
    • getRowNumber

      public int getRowNumber()
      Returns the zero-based index of the current position of this Row
    • getString

      public String getString(int columnIndex)
      Returns a String value from this Row at the column with the given index. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type type
    • getShort

      public short getShort(String columnName)
      Returns a short from this Row at the column of the given name. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type
    • getText

      public String getText(String columnName)
      Returns a String representing the text from this Row at the column of the given name. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type
    • getText

      public String getText(int columnIndex)
      Returns a String value from this Row at the column with the given index. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type type
    • getTime

      public LocalTime getTime(String columnName)
      Returns a LocalTime value from this Row at the column of the given name. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type type
    • getTime

      public LocalTime getTime(int columnIndex)
      Returns a LocalTime value from this Row at the column with the given index. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type type
    • getString

      public String getString(String columnName)
      Returns a String from this Row at the column of the given name. An IllegalStateException is thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type
    • isMissing

      public boolean isMissing(String columnName)
      Returns true if the value at columnName is missing, and false otherwise
    • hasNext

      public boolean hasNext()
      Returns true if there's at least one more row beyond the current one.
      Specified by:
      hasNext in interface Iterator<Row>
    • next

      public Row next()
      Increments the row pointer, making the next row's data accessible
      Specified by:
      next in interface Iterator<Row>
    • setMissing

      public void setMissing(int columnIndex)
      Sets the value of the given column at this Row to the appropriate missing-value indicator for the column type.
    • setMissing

      public void setMissing(String columnName)
      Sets the value of the given column at this Row to the appropriate missing-value indicator for the column type.
    • setBoolean

      public void setBoolean(int columnIndex, boolean value)
      Sets the value of the column at the given index and this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature
    • setBoolean

      public void setBoolean(String columnName, boolean value)
      Sets the value of the column with the given name at this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature
    • setDate

      public void setDate(int columnIndex, LocalDate value)
      Sets the value of the column at the given index and this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature
    • setDate

      public void setDate(String columnName, LocalDate value)
      Sets the value of the column with the given name at this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature
    • setDateTime

      public void setDateTime(int columnIndex, LocalDateTime value)
      Sets the value of the column at the given index and this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature
    • setDateTime

      public void setDateTime(String columnName, LocalDateTime value)
      Sets the value of the column with the given name at this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature
    • setInstant

      public void setInstant(int columnIndex, Instant value)
      Sets the value of the column at the given index and this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature
    • setInstant

      public void setInstant(String columnName, Instant value)
      Sets the value of the column with the given name at this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature
    • setDouble

      public void setDouble(int columnIndex, double value)
      Sets the value of the column at the given index and this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature
    • setDouble

      public void setDouble(String columnName, double value)
      Sets the value of the column with the given name at this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature
    • setFloat

      public void setFloat(int columnIndex, float value)
      Sets the value of the column at the given index and this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature
    • setFloat

      public void setFloat(String columnName, float value)
      Sets the value of the column with the given name at this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature
    • setInt

      public void setInt(int columnIndex, int value)
      Sets the value of the column at the given index and this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature
    • setInt

      public void setInt(String columnName, int value)
      Sets the value of the column with the given name at this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature
    • setLong

      public void setLong(int columnIndex, long value)
      Sets the value of the column at the given index and this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature
    • setLong

      public void setLong(String columnName, long value)
      Sets the value of the column with the given name at this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature
    • setShort

      public void setShort(int columnIndex, short value)
      Sets the value of the column at the given index and this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature
    • setShort

      public void setShort(String columnName, short value)
      Sets the value of the column with the given name at this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature
    • setString

      public void setString(int columnIndex, String value)
      Sets the value of the column at the given index and this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature
    • setString

      public void setString(String columnName, String value)
      Sets the value of the column with the given name at this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature
    • setText

      public void setText(int columnIndex, String value)
      Sets the value of the column at the given index and this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature
    • setText

      public void setText(String columnName, String value)
      Sets the value of the column with the given name at this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature
    • setTime

      public void setTime(int columnIndex, LocalTime value)
      Sets the value of the column at the given index and this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature
    • getNumber

      public double getNumber(String columnName)
      Returns a double representing the value held in the column with the given name at this row, for any numeric column type
    • getColumnType

      public ColumnType getColumnType(String columnName)
      Returns the type of the named column
    • getColumnType

      public ColumnType getColumnType(int columnIndex)
    • rowHash

      public int rowHash()
      Returns a hash computed on the values in the backing table at this row
    • toString

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

      public void setTime(String columnName, LocalTime value)
      Sets the value of the column with the given name at this Row to the given value. An IllegalStateException is * thrown if the column is not present in the Row and an IllegalArgumentException is thrown if it has a different type to that named in the method signature