Class Table
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 Summary
Fields Modifier and Type Field Description private ArrayList
fieldMissingDataFlags
Missing data flags/values for the IRecord objects.private ArrayList<String>
fieldNames
Field names for the values in the IRecord objects.private ArrayList<Class>
fieldTypes
Field types for the values in the IRecord objects.private IDataset
parentDataset
Parent container for the table.private ArrayList<IRecord>
records
TheIRecord
objects.private IMetadata
tableMetadata
Metadata for the table. -
Constructor Summary
-
Method Summary
Modifier and Type Method Description void
addRecord(IRecord record)
Add a singleIRecord
to the end of the container.void
addRecords(ArrayList<IRecord> records)
Add a set ofIRecord
objects to the end of the container.ArrayList
getFieldMissingDataFlags()
Gets the field missing data flags for this table.ArrayList<String>
getFieldNames()
Gets the field names for this table.ArrayList<Class>
getFieldTypes()
Gets the field types for this table.IMetadata
getMetadata()
Gets the metadata for this table.IDataset
getParentDataset()
Returns the dataset this table is part of.IRecord
getRecord(int index)
Get a singleIRecord
at an index.ArrayList<IRecord>
getRecords()
Get allIRecords
.void
setFieldMissingDataFlags(ArrayList fieldMissingDataFlags)
Sets the field missing data flags for this table.void
setFieldNames(ArrayList<String> fieldNames)
Sets the field names for this table.void
setFieldTypes(ArrayList<Class> fieldTypes)
Sets the field types for this table.void
setMetadata(IMetadata tableMetadata)
Sets the metadata for this table.void
setRecord(int index, IRecord record)
Sets a singleIRecord
in the table at index position.
-
Field Details
-
parentDataset
Parent container for the table. -
tableMetadata
Metadata for the table. -
fieldNames
Field names for the values in the IRecord objects. -
fieldTypes
Field types for the values in the IRecord objects. -
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
TheIRecord
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
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
Returns the dataset this table is part of.- Specified by:
getParentDataset
in interfaceIRecordHolder
- Returns:
- IDataset Parent dataset.
-
setMetadata
Sets the metadata for this table.- Specified by:
setMetadata
in interfaceIRecordHolder
- Parameters:
tableMetadata
- The metadata object for this table.
-
getMetadata
Gets the metadata for this table.- Specified by:
getMetadata
in interfaceIRecordHolder
- Returns:
- IMetadata The metadata object for this table.
-
setFieldNames
Sets the field names for this table.- Specified by:
setFieldNames
in interfaceIRecordHolder
- Parameters:
fieldNames
- The field names for this table.
-
getFieldNames
Gets the field names for this table.- Specified by:
getFieldNames
in interfaceIRecordHolder
- Returns:
- ArrayList The field names for this table.
-
setFieldTypes
Sets the field types for this table.- Specified by:
setFieldTypes
in interfaceIRecordHolder
- Parameters:
fieldTypes
- The field types for this table.
-
getFieldTypes
Gets the field types for this table.- Specified by:
getFieldTypes
in interfaceIRecordHolder
- Returns:
- ArrayList The field types for this table.
-
setFieldMissingDataFlags
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
Gets the field missing data flags for this table.- Returns:
- ArrayList The field missing data flags for this table.
-
setRecord
Sets a singleIRecord
in the table at index position.- Specified by:
setRecord
in interfaceIRecordHolder
- Parameters:
index
- Location of IRecords.record
- Records to add.
-
addRecord
Add a singleIRecord
to the end of the container.- Specified by:
addRecord
in interfaceIRecordHolder
- Parameters:
record
- Record to add.
-
addRecords
Add a set ofIRecord
objects to the end of the container.- Specified by:
addRecords
in interfaceIRecordHolder
- Parameters:
records
- Records to add.
-
getRecord
Get a singleIRecord
at an index.- Specified by:
getRecord
in interfaceIRecordHolder
- Parameters:
index
- Location of record.- Returns:
- IRecord Record requested.
-
getRecords
Get allIRecords
.- Specified by:
getRecords
in interfaceIRecordHolder
- Returns:
- ArrayList All Rows/Records.
-