Class ReferenceTable

  • All Implemented Interfaces:
    RootTable, TableDataSource

    public final class ReferenceTable
    extends FilterTable
    implements RootTable
    This is an implementation of a Table that references a DataTable as its parent. This is a one-to-one relationship unlike the VirtualTable class which is a one-to-many relationship.

    The entire purpose of this class is as a filter. We can use it to rename a DataTable class to any domain we feel like. This allows us to generate unique column names.

    For example, say we need to join the same table. We can use this method to ensure that the newly joined table won't have duplicate column names.

    This object implements RootTable.

    • Field Detail

      • table_name

        private TableName table_name
        This represents the new name of the table.
      • modified_table_def

        private DataTableDef modified_table_def
        The modified DataTableDef object for this reference.
    • Constructor Detail

      • ReferenceTable

        ReferenceTable​(Table table,
                       TableName tname)
        The Constructor.
      • ReferenceTable

        ReferenceTable​(Table table,
                       DataTableDef def)
        Constructs the ReferenceTable given the parent table, and a new DataTableDef that describes the columns in this table. This is used if we want to redefine the column names.

        Note that the given DataTableDef must contain the same number of columns as the parent table, and the columns must be the same type.

    • Method Detail

      • getTableName

        public TableName getTableName()
        Filters the name of the table. This returns the declared name of the table.
      • findFieldName

        public int findFieldName​(Variable v)
        Given a fully qualified variable field name, ie. 'APP.CUSTOMER.CUSTOMERID' this will return the column number the field is at. Returns -1 if the field does not exist in the table.
        Overrides:
        findFieldName in class FilterTable
      • getResolvedVariable

        public Variable getResolvedVariable​(int column)
        Returns a fully qualified Variable object that represents the name of the column at the given index. For example, new Variable(new TableName("APP", "CUSTOMER"), "ID")
        Overrides:
        getResolvedVariable in class FilterTable
      • typeEquals

        public boolean typeEquals​(RootTable table)
        Description copied from interface: RootTable
        This is function is used to check that two root tables are identical. This is used if we need to chect that the form of the table is the same. Such as in a union operation, when we can only union two tables with the identical columns.
        Specified by:
        typeEquals in interface RootTable