Class PageChannel

    • Field Detail

      • DEFAULT_BYTE_ORDER

        public static final ByteOrder DEFAULT_BYTE_ORDER
        default byte order of access mdb files
    • Constructor Detail

      • PageChannel

        public PageChannel​(FileChannel channel,
                           boolean closeChannel,
                           JetFormat format,
                           boolean autoSync)
        Parameters:
        channel - Channel containing the database
        format - Format of the database in the channel
    • Method Detail

      • isAutoSync

        public boolean isAutoSync()
      • startWrite

        public void startWrite()
        Begins a "logical" write operation. See finishWrite() for more details.
      • startExclusiveWrite

        public void startExclusiveWrite()
        Begins an exclusive "logical" write operation (throws an exception if another write operation is outstanding). See finishWrite() for more details.
      • finishWrite

        public void finishWrite()
                         throws IOException
        Completes a "logical" write operation. This method should be called in finally block which wraps a logical write operation (which is preceded by a startWrite() call). Logical write operations may be nested. If the database is configured for "auto-sync", the channel will be flushed when the outermost operation is complete,
        Throws:
        IOException
      • isWriting

        public boolean isWriting()
        Returns true if a logical write operation is in progress, false otherwise.
      • readPage

        public void readPage​(ByteBuffer buffer,
                             int pageNumber)
                      throws IOException
        Parameters:
        buffer - Buffer to read the page into
        pageNumber - Number of the page to read in (starting at 0)
        Throws:
        IOException
      • writePage

        public void writePage​(ByteBuffer page,
                              int pageNumber)
                       throws IOException
        Write a page to disk
        Parameters:
        page - Page to write
        pageNumber - Page number to write the page to
        Throws:
        IOException
      • writePage

        public void writePage​(ByteBuffer page,
                              int pageNumber,
                              int pageOffset)
                       throws IOException
        Write a page (or part of a page) to disk
        Parameters:
        page - Page to write
        pageNumber - Page number to write the page to
        pageOffset - offset within the page at which to start writing the page data
        Throws:
        IOException
      • deallocatePage

        public void deallocatePage​(int pageNumber)
                            throws IOException
        Deallocate a previously used page in the database.
        Throws:
        IOException
      • createPageBuffer

        public ByteBuffer createPageBuffer()
        Returns:
        A newly-allocated buffer that can be passed to readPage
      • createBuffer

        public static ByteBuffer createBuffer​(int size)
        Returns:
        A newly-allocated buffer of the given size and DEFAULT_BYTE_ORDER byte order
      • createBuffer

        public static ByteBuffer createBuffer​(int size,
                                              ByteOrder order)
        Returns:
        A newly-allocated buffer of the given size and byte order
      • isOpen

        public boolean isOpen()
        Specified by:
        isOpen in interface Channel
      • narrowBuffer

        public static ByteBuffer narrowBuffer​(ByteBuffer buffer,
                                              int position,
                                              int limit)
        Returns:
        a duplicate of the current buffer narrowed to the given position and limit. mark will be set at the current position.
      • wrap

        public static ByteBuffer wrap​(byte[] bytes)
        Returns a ByteBuffer wrapping the given bytes and configured with the default byte order.