Elexis: Das führende OpenSource-Arztpraxisprogamm
im deutschsprachigen Raum
Java doc für Elexis version 2.1.7.dev vom 01.09.2013

com.healthmarketscience.jackcess
Class PageChannel

java.lang.Object
  extended by com.healthmarketscience.jackcess.PageChannel
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.nio.channels.Channel

public class PageChannel
extends java.lang.Object
implements java.nio.channels.Channel, java.io.Flushable

Reads and writes individual pages in a database file


Constructor Summary
PageChannel(java.nio.channels.FileChannel channel, JetFormat format, boolean autoSync)
           
 
Method Summary
 int allocateNewPage()
          Allocates a new page in the database.
 void close()
           
 java.nio.ByteBuffer createBuffer(int size)
           
 java.nio.ByteBuffer createBuffer(int size, java.nio.ByteOrder order)
           
 java.nio.ByteBuffer createPageBuffer()
           
 void deallocatePage(int pageNumber)
          Deallocate a previously used page in the database.
 void flush()
           
 JetFormat getFormat()
           
 void initialize(Database database, CodecProvider codecProvider)
          Does second-stage initialization, must be called after construction.
 boolean isAutoSync()
           
 boolean isOpen()
           
static java.nio.ByteBuffer narrowBuffer(java.nio.ByteBuffer buffer, int position, int limit)
           
 void readPage(java.nio.ByteBuffer buffer, int pageNumber)
           
 int writeNewPage(java.nio.ByteBuffer page)
          Write a page to disk as a new page, appending it to the database
 void writePage(java.nio.ByteBuffer page, int pageNumber)
          Write a page to disk
 void writePage(java.nio.ByteBuffer page, int pageNumber, int pageOffset)
          Write a page (or part of a page) to disk
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PageChannel

public PageChannel(java.nio.channels.FileChannel channel,
                   JetFormat format,
                   boolean autoSync)
            throws java.io.IOException
Parameters:
channel - Channel containing the database
format - Format of the database in the channel
Throws:
java.io.IOException
Method Detail

initialize

public void initialize(Database database,
                       CodecProvider codecProvider)
                throws java.io.IOException
Does second-stage initialization, must be called after construction.

Throws:
java.io.IOException

getFormat

public JetFormat getFormat()

isAutoSync

public boolean isAutoSync()

readPage

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

writePage

public void writePage(java.nio.ByteBuffer page,
                      int pageNumber)
               throws java.io.IOException
Write a page to disk

Parameters:
page - Page to write
pageNumber - Page number to write the page to
Throws:
java.io.IOException

writePage

public void writePage(java.nio.ByteBuffer page,
                      int pageNumber,
                      int pageOffset)
               throws java.io.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:
java.io.IOException

writeNewPage

public int writeNewPage(java.nio.ByteBuffer page)
                 throws java.io.IOException
Write a page to disk as a new page, appending it to the database

Parameters:
page - Page to write
Returns:
Page number at which the page was written
Throws:
java.io.IOException

allocateNewPage

public int allocateNewPage()
                    throws java.io.IOException
Allocates a new page in the database. Data in the page is undefined until it is written in a call to writePage(ByteBuffer,int).

Throws:
java.io.IOException

deallocatePage

public void deallocatePage(int pageNumber)
                    throws java.io.IOException
Deallocate a previously used page in the database.

Throws:
java.io.IOException

createPageBuffer

public java.nio.ByteBuffer createPageBuffer()
Returns:
A newly-allocated buffer that can be passed to readPage

createBuffer

public java.nio.ByteBuffer createBuffer(int size)
Returns:
A newly-allocated buffer of the given size and DEFAULT_BYTE_ORDER byte order

createBuffer

public java.nio.ByteBuffer createBuffer(int size,
                                        java.nio.ByteOrder order)
Returns:
A newly-allocated buffer of the given size and byte order

flush

public void flush()
           throws java.io.IOException
Specified by:
flush in interface java.io.Flushable
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Specified by:
close in interface java.nio.channels.Channel
Throws:
java.io.IOException

isOpen

public boolean isOpen()
Specified by:
isOpen in interface java.nio.channels.Channel

narrowBuffer

public static java.nio.ByteBuffer narrowBuffer(java.nio.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.

Elexis: Das führende OpenSource-Arztpraxisprogamm
im deutschsprachigen Raum
Java doc für Elexis version 2.1.7.dev vom 01.09.2013