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 ArrayListfieldMissingDataFlagsMissing data flags/values for the IRecord objects.private ArrayList<String>fieldNamesField names for the values in the IRecord objects.private ArrayList<Class>fieldTypesField types for the values in the IRecord objects.private IDatasetparentDatasetParent container for the table.private ArrayList<IRecord>recordsTheIRecordobjects.private IMetadatatableMetadataMetadata for the table. -
Constructor Summary
-
Method Summary
Modifier and Type Method Description voidaddRecord(IRecord record)Add a singleIRecordto the end of the container.voidaddRecords(ArrayList<IRecord> records)Add a set ofIRecordobjects to the end of the container.ArrayListgetFieldMissingDataFlags()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.IMetadatagetMetadata()Gets the metadata for this table.IDatasetgetParentDataset()Returns the dataset this table is part of.IRecordgetRecord(int index)Get a singleIRecordat an index.ArrayList<IRecord>getRecords()Get allIRecords.voidsetFieldMissingDataFlags(ArrayList fieldMissingDataFlags)Sets the field missing data flags for this table.voidsetFieldNames(ArrayList<String> fieldNames)Sets the field names for this table.voidsetFieldTypes(ArrayList<Class> fieldTypes)Sets the field types for this table.voidsetMetadata(IMetadata tableMetadata)Sets the metadata for this table.voidsetRecord(int index, IRecord record)Sets a singleIRecordin 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
TheIRecordobjects.
-
-
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:
getParentDatasetin interfaceIRecordHolder- Returns:
- IDataset Parent dataset.
-
setMetadata
Sets the metadata for this table.- Specified by:
setMetadatain interfaceIRecordHolder- Parameters:
tableMetadata- The metadata object for this table.
-
getMetadata
Gets the metadata for this table.- Specified by:
getMetadatain interfaceIRecordHolder- Returns:
- IMetadata The metadata object for this table.
-
setFieldNames
Sets the field names for this table.- Specified by:
setFieldNamesin interfaceIRecordHolder- Parameters:
fieldNames- The field names for this table.
-
getFieldNames
Gets the field names for this table.- Specified by:
getFieldNamesin interfaceIRecordHolder- Returns:
- ArrayList The field names for this table.
-
setFieldTypes
Sets the field types for this table.- Specified by:
setFieldTypesin interfaceIRecordHolder- Parameters:
fieldTypes- The field types for this table.
-
getFieldTypes
Gets the field types for this table.- Specified by:
getFieldTypesin 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 singleIRecordin the table at index position.- Specified by:
setRecordin interfaceIRecordHolder- Parameters:
index- Location of IRecords.record- Records to add.
-
addRecord
Add a singleIRecordto the end of the container.- Specified by:
addRecordin interfaceIRecordHolder- Parameters:
record- Record to add.
-
addRecords
Add a set ofIRecordobjects to the end of the container.- Specified by:
addRecordsin interfaceIRecordHolder- Parameters:
records- Records to add.
-
getRecord
Get a singleIRecordat an index.- Specified by:
getRecordin interfaceIRecordHolder- Parameters:
index- Location of record.- Returns:
- IRecord Record requested.
-
getRecords
Get allIRecords.- Specified by:
getRecordsin interfaceIRecordHolder- Returns:
- ArrayList All Rows/Records.
-