java.lang.Object
io.github.ajevans.dbcode.data.structures.Table
All Implemented Interfaces:
IRecordHolder

public class Table
extends Object
implements IRecordHolder
Generic table class containing one or more IRecord objects, usually but not by necessity, Rows.

As all IRecord objects are held as IRecord, they'll need casting on access.

Maintains field names and types for the records.

Has its own metadata.

Author:
Andy Evans
To Do:
As records can be used with any IRecordHolder, it probably makes sense for them to directly link to fields as an independent object and class at some point.
Version: 1.0 01 Mar 2021
  • Field Details

    • parentDataset

      private IDataset parentDataset
      Parent container for the table.
    • tableMetadata

      private IMetadata tableMetadata
      Metadata for the table.
    • fieldNames

      private ArrayList<String> fieldNames
      Field names for the values in the IRecord objects.
    • fieldTypes

      private ArrayList<Class> fieldTypes
      Field types for the values in the IRecord objects.
    • fieldMissingDataFlags

      private ArrayList fieldMissingDataFlags
      Missing data flags/values for the IRecord objects. Each value at a specific index (column) in all the IRecord objects can have a separate specific flag.
    • records

      private ArrayList<IRecord> records
      The IRecord objects.
  • Constructor Details

    • Table

      public Table()
      Generic constructor made private to stop floating tables without a parent dataset.

      We need to be able to navigate towards the root dataset for metadata etc.

    • Table

      public Table​(IDataset parentDataset)
      Constructor for table with a parent dataset.

      This allows us to retrieve parent metadata if needed, as well as engage in any leaf-to-root tree navigation.

      Parameters:
      parentDataset - Parent Dataset.
  • Method Details

    • getParentDataset

      public IDataset getParentDataset()
      Returns the dataset this table is part of.
      Specified by:
      getParentDataset in interface IRecordHolder
      Returns:
      IDataset Parent dataset.
    • setMetadata

      public void setMetadata​(IMetadata tableMetadata)
      Sets the metadata for this table.
      Specified by:
      setMetadata in interface IRecordHolder
      Parameters:
      tableMetadata - The metadata object for this table.
    • getMetadata

      public IMetadata getMetadata()
      Gets the metadata for this table.
      Specified by:
      getMetadata in interface IRecordHolder
      Returns:
      IMetadata The metadata object for this table.
    • setFieldNames

      public void setFieldNames​(ArrayList<String> fieldNames)
      Sets the field names for this table.
      Specified by:
      setFieldNames in interface IRecordHolder
      Parameters:
      fieldNames - The field names for this table.
    • getFieldNames

      public ArrayList<String> getFieldNames()
      Gets the field names for this table.
      Specified by:
      getFieldNames in interface IRecordHolder
      Returns:
      ArrayList The field names for this table.
    • setFieldTypes

      public void setFieldTypes​(ArrayList<Class> fieldTypes)
      Sets the field types for this table.
      Specified by:
      setFieldTypes in interface IRecordHolder
      Parameters:
      fieldTypes - The field types for this table.
    • getFieldTypes

      public ArrayList<Class> getFieldTypes()
      Gets the field types for this table.
      Specified by:
      getFieldTypes in interface IRecordHolder
      Returns:
      ArrayList The field types for this table.
    • setFieldMissingDataFlags

      public void setFieldMissingDataFlags​(ArrayList fieldMissingDataFlags)
      Sets the field missing data flags for this table.

      Each value at a specific index (column) in all the IRecord objects can have a separate specific flag.

      Parameters:
      fieldMissingDataFlags - The field missing data flags for this table.
    • getFieldMissingDataFlags

      public ArrayList getFieldMissingDataFlags()
      Gets the field missing data flags for this table.
      Returns:
      ArrayList The field missing data flags for this table.
    • setRecord

      public void setRecord​(int index, IRecord record)
      Sets a single IRecord in the table at index position.
      Specified by:
      setRecord in interface IRecordHolder
      Parameters:
      index - Location of IRecords.
      record - Records to add.
    • addRecord

      public void addRecord​(IRecord record)
      Add a single IRecord to the end of the container.
      Specified by:
      addRecord in interface IRecordHolder
      Parameters:
      record - Record to add.
    • addRecords

      public void addRecords​(ArrayList<IRecord> records)
      Add a set of IRecord objects to the end of the container.
      Specified by:
      addRecords in interface IRecordHolder
      Parameters:
      records - Records to add.
    • getRecord

      public IRecord getRecord​(int index)
      Get a single IRecord at an index.
      Specified by:
      getRecord in interface IRecordHolder
      Parameters:
      index - Location of record.
      Returns:
      IRecord Record requested.
    • getRecords

      public ArrayList<IRecord> getRecords()
      Get all IRecords.
      Specified by:
      getRecords in interface IRecordHolder
      Returns:
      ArrayList All Rows/Records.