com.healthmarketscience.jackcess
Class DatabaseBuilder

java.lang.Object
  extended by com.healthmarketscience.jackcess.DatabaseBuilder

public class DatabaseBuilder
extends Object

Builder style class for opening/creating a Database.

Simple example usage:

   Database db = DatabaseBuilder.open(new File("test.mdb"));
 

Advanced example usage:

   Database db = new DatabaseBuilder(new File("test.mdb"))
     .setReadOnly(true)
     .open();
 

Author:
James Ahlborn
Usage:
General: This class is general use.

Constructor Summary
DatabaseBuilder()
           
DatabaseBuilder(File mdbFile)
           
 
Method Summary
 Database create()
          Creates a new Database using the configured information.
static Database create(Database.FileFormat fileFormat, File mdbFile)
          Create a new Database for the given fileFormat
 Database open()
          Opens an existingnew Database using the configured information.
static Database open(File mdbFile)
          Open an existing Database.
 DatabaseBuilder setAutoSync(boolean autoSync)
          Sets whether or not to enable auto-syncing on write.
 DatabaseBuilder setChannel(FileChannel channel)
          Sets a pre-opened FileChannel.
 DatabaseBuilder setCharset(Charset charset)
          Sets the Charset to use, if null, uses default.
 DatabaseBuilder setCodecProvider(CodecProvider codecProvider)
          Sets the CodecProvider for handling page encoding/decoding, may be null if no special encoding is necessary
 DatabaseBuilder setFile(File mdbFile)
          File containing an existing database for open() or target file for new database for create() (in which case, tf this file already exists, it will be overwritten.)
 DatabaseBuilder setFileFormat(Database.FileFormat fileFormat)
          Sets the version of new database (create() only).
 DatabaseBuilder setReadOnly(boolean readOnly)
          Sets flag which, iff true, will force opening file in read-only mode (open() only).
 DatabaseBuilder setTimeZone(TimeZone timeZone)
          Sets the TimeZone to use for interpreting dates, if null, uses default
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseBuilder

public DatabaseBuilder()

DatabaseBuilder

public DatabaseBuilder(File mdbFile)
Method Detail

setFile

public DatabaseBuilder setFile(File mdbFile)
File containing an existing database for open() or target file for new database for create() (in which case, tf this file already exists, it will be overwritten.)

Usage:
General: This method is general use.

setReadOnly

public DatabaseBuilder setReadOnly(boolean readOnly)
Sets flag which, iff true, will force opening file in read-only mode (open() only).

Usage:
General: This method is general use.

setAutoSync

public DatabaseBuilder setAutoSync(boolean autoSync)
Sets whether or not to enable auto-syncing on write. if true, write operations will be immediately flushed to disk upon completion. This leaves the database in a (fairly) consistent state on each write, but can be very inefficient for many updates. if false, flushing to disk happens at the jvm's leisure, which can be much faster, but may leave the database in an inconsistent state if failures are encountered during writing. Writes may be flushed at any time using Database.flush().

Usage:
Intermediate: This method requires moderate API knowledge.

setCharset

public DatabaseBuilder setCharset(Charset charset)
Sets the Charset to use, if null, uses default.

Usage:
Intermediate: This method requires moderate API knowledge.

setTimeZone

public DatabaseBuilder setTimeZone(TimeZone timeZone)
Sets the TimeZone to use for interpreting dates, if null, uses default

Usage:
Intermediate: This method requires moderate API knowledge.

setCodecProvider

public DatabaseBuilder setCodecProvider(CodecProvider codecProvider)
Sets the CodecProvider for handling page encoding/decoding, may be null if no special encoding is necessary

Usage:
Intermediate: This method requires moderate API knowledge.

setFileFormat

public DatabaseBuilder setFileFormat(Database.FileFormat fileFormat)
Sets the version of new database (create() only).

Usage:
General: This method is general use.

setChannel

public DatabaseBuilder setChannel(FileChannel channel)
Sets a pre-opened FileChannel. if provided explicitly, it will not be closed by the Database instance. This allows ultimate control of where the mdb file exists (which may not be on disk, e.g. MemFileChannel). If provided, the File parameter will be available from Database.getFile(), but otherwise ignored.

Usage:
Advanced: This method is for advanced/internal use.

open

public Database open()
              throws IOException
Opens an existingnew Database using the configured information.

Throws:
IOException

create

public Database create()
                throws IOException
Creates a new Database using the configured information.

Throws:
IOException

open

public static Database open(File mdbFile)
                     throws IOException
Open an existing Database. If the existing file is not writeable, the file will be opened read-only. Auto-syncing is enabled for the returned Database.

Parameters:
mdbFile - File containing the database
Throws:
IOException
See Also:
for more flexible Database opening
Usage:
General: This method is general use.

create

public static Database create(Database.FileFormat fileFormat,
                              File mdbFile)
                       throws IOException
Create a new Database for the given fileFormat

Parameters:
fileFormat - version of new database.
mdbFile - Location to write the new database to. If this file already exists, it will be overwritten.
Throws:
IOException
See Also:
for more flexible Database creation
Usage:
General: This method is general use.


Copyright © 2005-2013 Health Market Science. All Rights Reserved.