Class SubsetColumnTable

  • All Implemented Interfaces:
    RootTable, TableDataSource

    public final class SubsetColumnTable
    extends FilterTable
    implements RootTable
    This object is a filter that sits atop a Table object. Its purpose is to only provide a view of the columns that are required. In a Select query we may create a query with only the subset of columns that were originally in the table set. This object allows us to provide an interface to only the columns that the Table is allowed to access.

    This method implements RootTable which means a union operation will not decend further past this table when searching for the roots.

    Author:
    Tobias Downer
    • Constructor Detail

      • SubsetColumnTable

        public SubsetColumnTable​(Table parent)
        The Constructor.
    • Method Detail

      • setColumnMap

        public void setColumnMap​(int[] mapping,
                                 Variable[] aliases)
        Adds a column map into this table. The int array contains a map to the column in the parent object that we want the column number to reference. For example, to select columns 4, 8, 1, 2 into this new table, the array would be { 4, 8, 1, 2 }.
      • getColumnCount

        public int getColumnCount()
        Returns the number of columns in the table.
        Overrides:
        getColumnCount in class FilterTable
      • 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
      • getDataTableDef

        public DataTableDef getDataTableDef()
        Returns the DataTableDef object that describes the columns and name of this table. For a SubsetColumnTable object, this returns the columns that were mapped via the 'setColumnMap' method.
        Specified by:
        getDataTableDef in interface TableDataSource
        Overrides:
        getDataTableDef 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
      • getCellContents

        public final TObject getCellContents​(int column,
                                             int row)
        Returns an object that represents the information in the given cell in the table. This will generally be an expensive algorithm, so calls to it should be kept to a minimum. Note that the offset between two rows is not necessarily 1.
        Specified by:
        getCellContents in interface TableDataSource
        Overrides:
        getCellContents in class FilterTable
      • typeEquals

        public boolean typeEquals​(RootTable table)
        This function is used to check that two tables are identical. This is used in operations like 'union' that need to determine that the roots are infact of the same type.
        Specified by:
        typeEquals in interface RootTable
      • toString

        public java.lang.String toString()
        Returns a string that represents this table.
        Overrides:
        toString in class Table