Berkeley DB Java Edition
version 1.5.1

com.sleepycat.je
Class DatabaseConfig

java.lang.Object
  |
  +--com.sleepycat.je.DatabaseConfig
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
SecondaryConfig

public class DatabaseConfig
extends Object
implements Cloneable

Specify the attributes of a database.


Constructor Summary
DatabaseConfig()
          An instance created using the default constructor is initialized with the system's default settings.
 
Method Summary
 boolean getAllowCreate()
          Return true if the allowCreate mode is set.
 Comparator getBtreeComparator()
          Returns the Comparator used for key comparison on this database.
 Comparator getDuplicateComparator()
          Returns the Comparator used for duplicate data item comparison on this database.
 boolean getExclusiveCreate()
          Return true if the exclusiveCreate mode is set.
 boolean getOverrideBtreeComparator()
          Returns the override setting for the btree comparator.
 boolean getOverrideDuplicateComparator()
          Returns the override setting for the duplicate comparator.
 boolean getReadOnly()
          Return true if the database is in read-only mode.
 boolean getSortedDuplicates()
          Return true if the database supports sorted duplicate data items.
 boolean getTransactional()
          Return true if the database is to operate transactionally.
 void setAllowCreate(boolean allowCreate)
          Cause the open method to create the database if it does not already exist.
 void setBtreeComparator(Class btreeComparator)
          By default, a byte by byte lexicographic comparison is used for btree keys.
 void setDuplicateComparator(Class duplicateComparator)
          By default, a byte by byte lexicographic comparison is used for duplicate data items in a duplicate set.
 void setExclusiveCreate(boolean exclusiveCreate)
          Cause the open method to return an error if the database already exists and create the database if it does not already exist.
 void setOverrideBtreeComparator(boolean override)
          Set to true if the database exists and the btree comparator specified in this configuration object should override the current comparator.
 void setOverrideDuplicateComparator(boolean override)
          Set to true if the database exists and the duplicate comparator specified in this configuration object should override the current comparator.
 void setReadOnly(boolean readOnly)
          Configure the database in read-only mode.
 void setSortedDuplicates(boolean duplicatesAllowed)
          Configure the database to support sorted duplicate data items.
 void setTransactional(boolean transactional)
          Configure the database to operate transactionally.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseConfig

public DatabaseConfig()
An instance created using the default constructor is initialized with the system's default settings.

Method Detail

setAllowCreate

public void setAllowCreate(boolean allowCreate)
Cause the open method to create the database if it does not already exist.


getAllowCreate

public boolean getAllowCreate()
Return true if the allowCreate mode is set.


setExclusiveCreate

public void setExclusiveCreate(boolean exclusiveCreate)
Cause the open method to return an error if the database already exists and create the database if it does not already exist. The exclusiveCreate mode is only meaningful if specified with the allowCreate mode.


getExclusiveCreate

public boolean getExclusiveCreate()
Return true if the exclusiveCreate mode is set.


setSortedDuplicates

public void setSortedDuplicates(boolean duplicatesAllowed)
Configure the database to support sorted duplicate data items.


getSortedDuplicates

public boolean getSortedDuplicates()
Return true if the database supports sorted duplicate data items.


setTransactional

public void setTransactional(boolean transactional)
                      throws IllegalArgumentException
Configure the database to operate transactionally.

IllegalArgumentException

getTransactional

public boolean getTransactional()
                         throws IllegalArgumentException
Return true if the database is to operate transactionally.

IllegalArgumentException

setReadOnly

public void setReadOnly(boolean readOnly)
Configure the database in read-only mode.


getReadOnly

public boolean getReadOnly()
Return true if the database is in read-only mode.


setBtreeComparator

public void setBtreeComparator(Class btreeComparator)
By default, a byte by byte lexicographic comparison is used for btree keys. To customize the comparison, supply a different Comparator.

The btreeComparator class must implement java.util.Comparator.

JE will instantiate the Comparator with a zero-parameter constructor, so the Comparator should not be dependent on constructor parameters. In addition, although it is possible to change the comparator for an existing database, care must be taken that the new comparator provides compatible results with the previous comparator, or database corruption will occur.

The Comparator.compare() method is passed the byte arrays that are stored in the database. If you know how your data is organized in the byte array, then you can write a comparison routine that directly examines the contents of the arrays. Otherwise, you have to reconstruct your original objects, and then perform the comparison. See the Getting Started Guide for examples.

The comparator for an existing database will not be overridden unless setOverrideBtreeComparator() is set to true.


getBtreeComparator

public Comparator getBtreeComparator()
Returns the Comparator used for key comparison on this database.


setOverrideBtreeComparator

public void setOverrideBtreeComparator(boolean override)
Set to true if the database exists and the btree comparator specified in this configuration object should override the current comparator.

Parameters:
override - Set to true to override the existing comparator.

getOverrideBtreeComparator

public boolean getOverrideBtreeComparator()
Returns the override setting for the btree comparator.


setDuplicateComparator

public void setDuplicateComparator(Class duplicateComparator)
By default, a byte by byte lexicographic comparison is used for duplicate data items in a duplicate set. To customize the comparison, supply a different Comparator.

The duplicateComparator class must implement java.util.Comparator.

JE will instantiate the Comparator with a zero-parameter constructor, so the Comparator should not be dependent on constructor parameters. In addition, although it is possible to change the comparator for an existing database, care must be taken that the new comparator provides compatible results with the previous comparator, or database corruption will occur.

The Comparator.compare() method is passed the byte arrays that are stored in the database. If you know how your data is organized in the byte array, then you can write a comparison routine that directly examines the contents of the arrays. Otherwise, you have to reconstruct your original objects, and then perform the comparison. See the Getting Started Guide for examples.

The comparator for an existing database will not be overridden unless setOverrideDuplicateComparator() is set to true.


getDuplicateComparator

public Comparator getDuplicateComparator()
Returns the Comparator used for duplicate data item comparison on this database.


setOverrideDuplicateComparator

public void setOverrideDuplicateComparator(boolean override)
Set to true if the database exists and the duplicate comparator specified in this configuration object should override the current comparator.

Parameters:
override - Set to true to override the existing comparator.

getOverrideDuplicateComparator

public boolean getOverrideDuplicateComparator()
Returns the override setting for the duplicate comparator.


Berkeley DB Java Edition
version 1.5.1

Copyright (c) 1996-2004 Sleepycat Software, Inc. - All rights reserved.