Package tech.tablesaw.api
Class Row
- java.lang.Object
-
- tech.tablesaw.api.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 tableRow(Table table, int rowNumber)Constructs a Row object for the given Table, with the Row positioned at the given 0-based indexRow(TableSlice tableSlice)Constructs a Row object for the given TableSliceRow(TableSlice tableSlice, int rowNumber)Constructs a Row object for the given TableSlice, with the Row positioned at the given 0-based index
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidat(int rowNumber)Moves this Row to the given 0-based row indexColumn<?>column(int columnIndex)intcolumnCount()Returns the number of columns in this RowList<String>columnNames()Returns a list containing the names of each column in the rowbooleanequals(Object obj)Returns true if every value is equal to the corresponding value in the given rowintgetBackingRowNumber()Returns the row number in the table backing the slice behind this row.BooleangetBoolean(int columnIndex)Returns a Boolean value from this Row at the given column index.BooleangetBoolean(String columnName)Returns a Boolean value from this Row at the column of the given name.bytegetBooleanAsByte(int columnIndex)Returns an element from a Boolean column in its internal byte form, avoiding boxingbytegetBooleanAsByte(String columnName)Returns an element from a Boolean column in its internal byte form, avoiding boxingColumnTypegetColumnType(int columnIndex)ColumnTypegetColumnType(String columnName)Returns the type of the named columnLocalDategetDate(int columnIndex)Returns a LocalDate value from this Row at the column with the given index.LocalDategetDate(String columnName)Returns a LocalDate value from this Row at the column of the given name.LocalDateTimegetDateTime(int columnIndex)Returns a LocalDateTime from this Row at the column with the given index.LocalDateTimegetDateTime(String columnName)Returns a LocalDateTime value from this Row at the column of the given name.doublegetDouble(int columnIndex)Returns a double from this Row at the column with the given index.doublegetDouble(String columnName)Returns a double from this Row at the column of the given name.floatgetFloat(int columnIndex)Returns a float from this Row at the column with the given index.floatgetFloat(String columnName)Returns a float from this Row at the column of the given name.InstantgetInstant(int columnIndex)Returns an Instant from this Row at the column with the given index.InstantgetInstant(String columnName)Returns an Instant value from this Row at the column of the given name.intgetInt(int columnIndex)Returns an int from this Row at the column with the given index.intgetInt(String columnName)Returns an int from this Row at the column of the given name.longgetLong(int columnIndex)Returns a long from this Row at the column with the given index.longgetLong(String columnName)Returns a long from this Row at the column of the given name.doublegetNumber(String columnName)Returns a double representing the value held in the column with the given name at this row, for any numeric column typeObjectgetObject(int columnIndex)Returns an Object representing the LocalTime from this Row at the column with the given index.ObjectgetObject(String columnName)Returns an Object representing the value from this Row at the column of the given name.intgetPackedDate(int columnIndex)Returns an int representing the LocalTime from this Row at the column with the given index.intgetPackedDate(String columnName)Returns an int representing the LocalDate from this Row at the column of the given name.longgetPackedDateTime(int columnIndex)Returns an long representing the LocalTime from this Row at the column with the given index.longgetPackedDateTime(String columnName)Returns a long representing the LocalDateTime from this Row at the column of the given name.longgetPackedInstant(int columnIndex)Returns an long representing the LocalTime from this Row at the column with the given index.longgetPackedInstant(String columnName)Returns a long representing the Instant from this Row at the column of the given name.intgetPackedTime(int columnIndex)Returns an int representing the LocalTime from this Row at the column with the given index.intgetPackedTime(String columnName)Returns an int representing the LocalTime from this Row at the column of the given name.intgetRowNumber()Returns the zero-based index of the current position of this RowshortgetShort(int columnIndex)Returns a short value from this Row at the column with the given index.shortgetShort(String columnName)Returns a short from this Row at the column of the given name.StringgetString(int columnIndex)Returns a String value from this Row at the column with the given index.StringgetString(String columnName)Returns a String from this Row at the column of the given name.LocalTimegetTime(int columnIndex)Returns a LocalTime value from this Row at the column with the given index.LocalTimegetTime(String columnName)Returns a LocalTime value from this Row at the column of the given name.inthashCode()Returns a hash computed on the values in the backing table at this rowbooleanhasNext()Returns true if there's at least one more row beyond the current one.booleanisMissing(String columnName)Returns true if the value at columnName is missing, and false otherwiseRownext()Increments the row pointer, making the next row's data accessiblevoidsetBoolean(int columnIndex, boolean value)Sets the value of the column at the given index and this Row to the given value.voidsetBoolean(String columnName, boolean value)Sets the value of the column with the given name at this Row to the given value.voidsetBooleanAsByte(int columnIndex, byte value)voidsetBooleanAsByte(String columnName, byte value)voidsetDate(int columnIndex, LocalDate value)Sets the value of the column at the given index and this Row to the given value.voidsetDate(String columnName, LocalDate value)Sets the value of the column with the given name at this Row to the given value.voidsetDateTime(int columnIndex, LocalDateTime value)Sets the value of the column at the given index and this Row to the given value.voidsetDateTime(String columnName, LocalDateTime value)Sets the value of the column with the given name at this Row to the given value.voidsetDouble(int columnIndex, double value)Sets the value of the column at the given index and this Row to the given value.voidsetDouble(String columnName, double value)Sets the value of the column with the given name at this Row to the given value.voidsetFloat(int columnIndex, float value)Sets the value of the column at the given index and this Row to the given value.voidsetFloat(String columnName, float value)Sets the value of the column with the given name at this Row to the given value.voidsetInstant(int columnIndex, Instant value)Sets the value of the column at the given index and this Row to the given value.voidsetInstant(String columnName, Instant value)Sets the value of the column with the given name at this Row to the given value.voidsetInt(int columnIndex, int value)Sets the value of the column at the given index and this Row to the given value.voidsetInt(String columnName, int value)Sets the value of the column with the given name at this Row to the given value.voidsetLong(int columnIndex, long value)Sets the value of the column at the given index and this Row to the given value.voidsetLong(String columnName, long value)Sets the value of the column with the given name at this Row to the given value.voidsetMissing(int columnIndex)Sets the value of the given column at this Row to the appropriate missing-value indicator for the column type.voidsetMissing(String columnName)Sets the value of the given column at this Row to the appropriate missing-value indicator for the column type.voidsetPackedDate(int columnIndex, int value)voidsetPackedDate(String columnName, int value)voidsetPackedDateTime(int columnIndex, long value)voidsetPackedDateTime(String columnName, long value)voidsetPackedInstant(int columnIndex, long value)voidsetPackedInstant(String columnName, long value)voidsetPackedTime(int columnIndex, int value)voidsetPackedTime(String columnName, int value)voidsetShort(int columnIndex, short value)Sets the value of the column at the given index and this Row to the given value.voidsetShort(String columnName, short value)Sets the value of the column with the given name at this Row to the given value.voidsetString(int columnIndex, String value)Sets the value of the column at the given index and this Row to the given value.voidsetString(String columnName, String value)Sets the value of the column with the given name at this Row to the given value.voidsetTime(int columnIndex, LocalTime value)Sets the value of the column at the given index and this Row to the given value.voidsetTime(String columnName, LocalTime value)Sets the value of the column with the given name at this Row to the given value.StringtoString()ColumnTypetype(int columnIndex)-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
-
-
-
Constructor Detail
-
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 Detail
-
type
public ColumnType type(int columnIndex)
-
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
-
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.
-
next
public Row next()
Increments the row pointer, making the next row's data accessible
-
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
-
setPackedDate
public void setPackedDate(int columnIndex, int value)
-
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
-
setPackedDate
public void setPackedDate(String columnName, int value)
-
setPackedTime
public void setPackedTime(int columnIndex, int value)
-
setPackedDateTime
public void setPackedDateTime(int columnIndex, long value)
-
setPackedInstant
public void setPackedInstant(int columnIndex, long value)
-
setPackedTime
public void setPackedTime(String columnName, int value)
-
setPackedDateTime
public void setPackedDateTime(String columnName, long value)
-
setPackedInstant
public void setPackedInstant(String columnName, long value)
-
setBooleanAsByte
public void setBooleanAsByte(String columnName, byte value)
-
setBooleanAsByte
public void setBooleanAsByte(int columnIndex, byte value)
-
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
-
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
-
getBackingRowNumber
public int getBackingRowNumber()
Returns the row number in the table backing the slice behind this row. This value may differ from the rowNumber() if the slice covers less than the entire table
-
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)
-
column
public Column<?> column(int columnIndex)
-
equals
public boolean equals(Object obj)
Returns true if every value is equal to the corresponding value in the given row
-
hashCode
public int hashCode()
Returns a hash computed on the values in the backing table at this row
-
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
-
-