Class Row
java.lang.Object
io.github.ajevans.dbcode.data.structures.Row
- All Implemented Interfaces:
IRecord
public class Row extends Object implements IRecord
Generic row class containing one or more value objects.
While this might usually be used within a Table
, it will work
with any IRecordHolder
. Has its own metadata in which it sets
a row version number to track edits for, e.g. rollback.
Rows should refer to their container for field information.
- Author:
- Andy Evans
- To Do:
- It might be nice to have free-floating rows with access to their own fields, but maybe that's another IRecord type; for now any IRecordHolder needs to contain the field info., Originally this class extended ArrayList, but probably makes sense to wrap an ArrayList instead: allows for latter addition of fields etc. on a consistent basis.
- Version: 1.0 01 Mar 2021
-
Field Summary
Fields Modifier and Type Field Description private Metadata
metadata
Metadata for the row.private IRecordHolder
parentRecordHolder
Parent container for the row.private ArrayList
values
Storage for values. -
Constructor Summary
Constructors Modifier Constructor Description private
Row()
Generic constructor made private to stop floating rows without a parent container.Row(IRecordHolder parentRecordHolder)
Constructor for rows with a parent container. -
Method Summary
Modifier and Type Method Description void
addValue(Object value)
Add a single value to end of row.void
decrementVersion()
Decrement the row version number in metadata.IRecordHolder
getParentRecordHolder()
Returns the record holder this row is part of.Object
getValue(int index)
Get a single value at an index.ArrayList
getValues()
Get all values.int
getVersion()
Get the row version number.void
incrementVersion()
Increment the row version number in metadata.void
setValue(int index, Object value)
Set a single value.String
toString()
For printing rows.
-
Field Details
-
metadata
Metadata for the row. Includes row version number. -
values
Storage for values. -
parentRecordHolder
Parent container for the row.
-
-
Constructor Details
-
Row
private Row()Generic constructor made private to stop floating rows without a parent container. -
Row
Constructor for rows with a parent container.This allows us to retrieve parent metadata if needed, as well as engage in any leaf-to-root tree navigation.
Metadata version number starts at 1.
Also allows the row to gain its field info.
- Parameters:
parentRecordHolder
- Parent container.
-
-
Method Details
-
getParentRecordHolder
Returns the record holder this row is part of.- Specified by:
getParentRecordHolder
in interfaceIRecord
- Returns:
- IRecordHolder Parent record holder.
-
incrementVersion
public void incrementVersion()Increment the row version number in metadata. -
decrementVersion
public void decrementVersion()Decrement the row version number in metadata. -
getVersion
public int getVersion()Get the row version number.- Returns:
- int Row version number.
-
setValue
Set a single value. -
addValue
Add a single value to end of row. -
getValue
Get a single value at an index. -
getValues
Get all values. -
toString
For printing rows.Mainly added to print calender objects reasonably.
-