Class RowData

  • All Implemented Interfaces:
    Types

    public class RowData
    extends java.lang.Object
    implements Types
    Represents a row of data to be added into a table. The row data is linked to a TableField that describes the cell information within a row.

    There are two types of RowData object. Those that are empty and contain blank data, and those that contain information to either be inserted into a table, or has be retrieved from a row.

    NOTE: Any RowData objects that need to be set to 'null' should be done so explicitly. NOTE: We must call a 'setColumnData' method for _every_ column in the row to form. NOTE: This method (or derived classes) must only use safe methods in DataTable. (ie. getRowCount, etc are out).

    • Field Detail

      • system

        private TransactionSystem system
        The TransactionSystem this RowData is a context of.
      • table

        private TableDataSource table
        The TableDataSource object that this RowData is in, or is destined to be in.
      • table_def

        private DataTableDef table_def
        The definition of the table.
      • data_cell_list

        private TObject[] data_cell_list
        A list of TObject objects in the table.
      • col_count

        private int col_count
        The number of columns in the row.
    • Constructor Detail

      • RowData

        public RowData​(TransactionSystem system,
                       int col_count)
        To create a RowData object without an underlying table. This is for copying from one table to a different one.
      • RowData

        public RowData​(TableDataSource table)
        The Constructor generates a blank row.
    • Method Detail

      • setFromRow

        void setFromRow​(int row)
        Populates the RowData object with information from a specific row from the underlying DataTable.
      • isSameTable

        boolean isSameTable​(DataTable tab)
        Returns the table object this row data is assigned to. This is used to ensure we don't try to use a row data in a different table to what it was created from.
      • setColumnData

        public void setColumnData​(int column,
                                  TObject cell)
        Sets up a column by casting the value from the given TObject to a type that is compatible with the column. This is useful when we are copying information from one table to another.
      • setColumnDataFromObject

        public void setColumnDataFromObject​(int column,
                                            java.lang.Object ob)
        Sets up a column from an Object.
      • setColumnDataFromTObject

        public void setColumnDataFromTObject​(int column,
                                             TObject ob)
        Sets up a column from a TObject.
      • setColumnToNull

        public void setColumnToNull​(int column)
        This is a special case situation for setting the column cell to 'null'.
      • setColumnToDefault

        public void setColumnToDefault​(int column,
                                       QueryContext context)
        Sets the given column number to the default value for this column.
      • getCellData

        public TObject getCellData​(int column)
        Returns the TObject that represents the information in the given column of the row.
      • getColumnName

        public java.lang.String getColumnName​(int column)
        Returns the name of the given column number.
      • findFieldName

        public int findFieldName​(java.lang.String column_name)
        Finds the field in this RowData with the given name.
      • getColumnCount

        public int getColumnCount()
        Returns the number of columns (cells) in this row.
      • evaluate

        TObject evaluate​(Expression expression,
                         QueryContext context)
        Evaluates the expression and returns the object it evaluates to using the local VariableResolver to resolve variables in the expression.
      • evaluate

        void evaluate​(Assignment assignment,
                      QueryContext context)
        Evaluates a single assignment on this RowData object. A VariableResolver is made which resolves to variables only within this RowData context.
      • setDefaultForRest

        public void setDefaultForRest​(QueryContext context)
                               throws DatabaseException
        Any columns in the row of data that haven't been set yet (they will be 'null') will be set to the default value during this method. This should be called after the row data has initially been set with values from some source.
        Throws:
        DatabaseException
      • setupEntire

        public void setupEntire​(int[] col_indices,
                                java.util.List insert_elements,
                                QueryContext context)
                         throws DatabaseException
        Sets up an entire row given the list of insert elements and a list of indices to the columns to set. An insert element is either an expression that is resolved to a constant, or the string "DEFAULT" which indicates the value should be set to the default value of the column.
        Throws:
        DatabaseException
      • setupEntire

        public void setupEntire​(int[] col_indices,
                                Expression[] exps,
                                QueryContext context)
                         throws DatabaseException
        Sets up an entire row given the array of Expressions and a list of indices to the columns to set. Any columns that are not set by this method are set to the default value as defined for the column.
        Throws:
        DatabaseException
      • toString

        public java.lang.String toString()
        Returns a string representation of this row.
        Overrides:
        toString in class java.lang.Object
      • getVariableResolver

        private VariableResolver getVariableResolver()
        Returns a VariableResolver to use within this RowData context.