Class TableImpl

    • Field Detail

      • TYPE_SYSTEM

        public static final byte TYPE_SYSTEM
        Table type code for system tables
        See Also:
        Constant Field Values
        Usage:
        Intermediate: This class requires moderate API knowledge.
      • TYPE_USER

        public static final byte TYPE_USER
        Table type code for user tables
        See Also:
        Constant Field Values
        Usage:
        Intermediate: This class requires moderate API knowledge.
    • Method Detail

      • isHidden

        public boolean isHidden()
        Description copied from interface: Table
        Whether or not this table has been marked as hidden.
        Specified by:
        isHidden in interface Table
        Specified by:
        isHidden in interface TableDefinition
      • isSystem

        public boolean isSystem()
        Description copied from interface: Table
        Whether or not this table is a system (internal) table.
        Specified by:
        isSystem in interface Table
        Specified by:
        isSystem in interface TableDefinition
      • getMaxColumnCount

        public int getMaxColumnCount()
        Usage:
        Advanced: This method is for advanced/internal use.
      • getFormat

        public JetFormat getFormat()
        Usage:
        Advanced: This method is for advanced/internal use.
      • getPageChannel

        public PageChannel getPageChannel()
        Usage:
        Advanced: This method is for advanced/internal use.
      • getErrorHandler

        public ErrorHandler getErrorHandler()
        Description copied from interface: Table
        Gets the currently configured ErrorHandler (always non-null). This will be used to handle all errors unless overridden at the Cursor level.
        Specified by:
        getErrorHandler in interface Table
      • setErrorHandler

        public void setErrorHandler​(ErrorHandler newErrorHandler)
        Description copied from interface: Table
        Sets a new ErrorHandler. If null, resets to using the ErrorHandler configured at the Database level.
        Specified by:
        setErrorHandler in interface Table
      • getTableDefPageNumber

        public int getTableDefPageNumber()
      • setAllowAutoNumberInsert

        public void setAllowAutoNumberInsert​(Boolean allowAutoNumInsert)
        Description copied from interface: Table
        Sets the new auto number insert policy for the Table. If null, resets to using the policy configured at the Database level.
        Specified by:
        setAllowAutoNumberInsert in interface Table
      • createRowState

        public TableImpl.RowState createRowState()
        Usage:
        Advanced: This method is for advanced/internal use.
      • getOwnedPagesCursor

        public UsageMap.PageCursor getOwnedPagesCursor()
        Usage:
        Advanced: This method is for advanced/internal use.
      • getApproximateOwnedPageCount

        public int getApproximateOwnedPageCount()
        Returns the approximate number of database pages owned by this table and all related indexes (this number does not take into account pages used for large OLE/MEMO fields).

        To calculate the approximate number of bytes owned by a table: int approxTableBytes = (table.getApproximateOwnedPageCount() * table.getFormat().PAGE_SIZE);

        Usage:
        Intermediate: This method requires moderate API knowledge.
      • hasColumn

        public boolean hasColumn​(String name)
      • getPropertyMaps

        public PropertyMaps getPropertyMaps()
                                     throws IOException
        Returns:
        all PropertyMaps for this table (and columns)
        Throws:
        IOException
        Usage:
        Advanced: This method is for advanced/internal use.
      • getIndexDatas

        public List<IndexData> getIndexDatas()
        Returns:
        All of the IndexData on this table (unmodifiable List)
        Usage:
        Advanced: This method is for advanced/internal use.
      • getLogicalIndexCount

        public int getLogicalIndexCount()
        Only called by unit tests
        Usage:
        Advanced: This method is for advanced/internal use.
      • getDefaultCursor

        public CursorImpl getDefaultCursor()
        Specified by:
        getDefaultCursor in interface Table
        Returns:
        a simple Cursor, initialized on demand and held by this table. This cursor backs the row traversal methods available on the Table interface. For advanced Table traversal and manipulation, use the Cursor directly.
      • newCursor

        public CursorBuilder newCursor()
        Description copied from interface: Table
        Convenience method for constructing a new CursorBuilder for this Table.
        Specified by:
        newCursor in interface Table
      • deleteRow

        public Row deleteRow​(Row row)
                      throws IOException
        Description copied from interface: Table
        Delete the given row. Provided Row must have previously been returned from this Table.
        Specified by:
        deleteRow in interface Table
        Returns:
        the given row
        Throws:
        IOException
      • deleteRow

        public RowId deleteRow​(RowId rowId)
                        throws IOException
        Delete the row with the given id. Provided RowId must have previously been returned from this Table.
        Returns:
        the given rowId
        Throws:
        IllegalStateException - if the given row is not valid
        IOException
        Usage:
        Intermediate: This method requires moderate API knowledge.
      • positionAtRowHeader

        public static ByteBuffer positionAtRowHeader​(TableImpl.RowState rowState,
                                                     RowIdImpl rowId)
                                              throws IOException
        Sets a new buffer to the correct row header page using the given rowState according to the given rowId. Deleted state is determined, but overflow row pointers are not followed.
        Returns:
        a ByteBuffer of the relevant page, or null if row was invalid
        Throws:
        IOException
        Usage:
        Advanced: This method is for advanced/internal use.
      • positionAtRowData

        public static ByteBuffer positionAtRowData​(TableImpl.RowState rowState,
                                                   RowIdImpl rowId)
                                            throws IOException
        Sets the position and limit in a new buffer using the given rowState according to the given row number and row end, following overflow row pointers as necessary.
        Returns:
        a ByteBuffer narrowed to the actual row data, or null if row was invalid or deleted
        Throws:
        IOException
        Usage:
        Advanced: This method is for advanced/internal use.
      • asRowWithRowId

        public Object[] asRowWithRowId​(Map<String,​?> rowMap)
        Converts a map of columnName -> columnValue to an array of row values appropriate for a call to addRow(Object...), where the generated RowId will be an extra value at the end of the array.
        See Also:
        ColumnImpl.RETURN_ROW_ID
        Usage:
        Intermediate: This method requires moderate API knowledge.
      • addRow

        public Object[] addRow​(Object... row)
                        throws IOException
        Description copied from interface: Table
        Adds a single row to this table and writes it to disk. The values are expected to be given in the order that the Columns are listed by the Table.getColumns() method. This is by default the storage order of the Columns in the database, however this order can be influenced by setting the ColumnOrder via Database.setColumnOrder(com.healthmarketscience.jackcess.Table.ColumnOrder) prior to opening the Table. The Table.asRow(java.util.Map<java.lang.String, ?>) method can be used to easily convert a row Map into the appropriate row array for this Table.

        Note, if this table has an auto-number column, the value generated will be put back into the given row array (assuming the given row array is at least as long as the number of Columns in this Table).

        Specified by:
        addRow in interface Table
        Parameters:
        row - row values for a single row. the given row array will be modified if this table contains an auto-number column, otherwise it will not be modified.
        Returns:
        the given row values if long enough, otherwise a new array. the returned array will contain any autonumbers generated
        Throws:
        IOException
      • addRows

        public List<? extends Object[]> addRows​(List<? extends Object[]> rows)
                                         throws IOException
        Description copied from interface: Table
        Add multiple rows to this table, only writing to disk after all rows have been written, and every time a data page is filled. This is much more efficient than calling Table.addRow(java.lang.Object...) multiple times.

        Note, if this table has an auto-number column, the values written will be put back into the given row arrays (assuming the given row array is at least as long as the number of Columns in this Table).

        Most exceptions thrown from this method will be wrapped with a BatchUpdateException which gives useful information in the case of a partially successful write.

        Specified by:
        addRows in interface Table
        Parameters:
        rows - List of Object[] row values. the rows will be modified if this table contains an auto-number column, otherwise they will not be modified.
        Returns:
        the given row values list (unless row values were to small), with appropriately sized row values (the ones passed in if long enough). the returned arrays will contain any autonumbers generated
        Throws:
        IOException
        See Also:
        for more details on row arrays
      • updateRow

        public Row updateRow​(Row row)
                      throws IOException
        Description copied from interface: Table
        Update the given row. Provided Row must have previously been returned from this Table.
        Specified by:
        updateRow in interface Table
        Returns:
        the given row, updated with the current row values
        Throws:
        IOException
      • updateRow

        public Object[] updateRow​(RowId rowId,
                                  Object... row)
                           throws IOException
        Update the row with the given id. Provided RowId must have previously been returned from this Table.
        Returns:
        the given row, updated with the current row values
        Throws:
        IllegalStateException - if the given row is not valid, or deleted.
        IOException
        Usage:
        Intermediate: This method requires moderate API knowledge.
      • updateValue

        public void updateValue​(Column column,
                                RowId rowId,
                                Object value)
                         throws IOException
        Update the given column's value for the given row id. Provided RowId must have previously been returned from this Table.
        Throws:
        IllegalStateException - if the given row is not valid, or deleted.
        IOException
        Usage:
        Intermediate: This method requires moderate API knowledge.
      • getRowCount

        public int getRowCount()
        Specified by:
        getRowCount in interface Table
      • display

        public String display()
                       throws IOException
        Returns:
        A simple String representation of the entire table in tab-delimited format
        Throws:
        IOException
        Usage:
        General: This method is general use.
      • display

        public String display​(long limit)
                       throws IOException
        Parameters:
        limit - Maximum number of rows to display
        Returns:
        A simple String representation of the entire table in tab-delimited format
        Throws:
        IOException
        Usage:
        General: This method is general use.
      • addDataPageRow

        public static int addDataPageRow​(ByteBuffer dataPage,
                                         int rowSize,
                                         JetFormat format,
                                         int rowFlags)
        Updates free space and row info for a new row of the given size in the given data page. Positions the page for writing the row data.
        Returns:
        the row number of the new row
        Usage:
        Advanced: This method is for advanced/internal use.
      • isDeletedRow

        public static boolean isDeletedRow​(short rowStart)
        Usage:
        Advanced: This method is for advanced/internal use.
      • isOverflowRow

        public static boolean isOverflowRow​(short rowStart)
        Usage:
        Advanced: This method is for advanced/internal use.
      • cleanRowStart

        public static short cleanRowStart​(short rowStart)
        Usage:
        Advanced: This method is for advanced/internal use.
      • findRowStart

        public static short findRowStart​(ByteBuffer buffer,
                                         int rowNum,
                                         JetFormat format)
        Usage:
        Advanced: This method is for advanced/internal use.
      • getRowStartOffset

        public static int getRowStartOffset​(int rowNum,
                                            JetFormat format)
        Usage:
        Advanced: This method is for advanced/internal use.
      • findRowEnd

        public static short findRowEnd​(ByteBuffer buffer,
                                       int rowNum,
                                       JetFormat format)
        Usage:
        Advanced: This method is for advanced/internal use.
      • getRowEndOffset

        public static int getRowEndOffset​(int rowNum,
                                          JetFormat format)
        Usage:
        Advanced: This method is for advanced/internal use.
      • getRowSpaceUsage

        public static int getRowSpaceUsage​(int rowSize,
                                           JetFormat format)
        Usage:
        Advanced: This method is for advanced/internal use.
      • rowFitsOnDataPage

        public static boolean rowFitsOnDataPage​(int rowLength,
                                                ByteBuffer dataPage,
                                                JetFormat format)
        Returns true if a row of the given size will fit on the given data page, false otherwise.
        Usage:
        Advanced: This method is for advanced/internal use.