com.sleepycat.persist.impl
Class PersistCatalog

java.lang.Object
  extended by com.sleepycat.persist.impl.PersistCatalog
All Implemented Interfaces:
Catalog

public class PersistCatalog
extends Object
implements Catalog

The catalog of class formats for a store, along with its associated model and mutations.

Author:
Mark Hayes

Constructor Summary
PersistCatalog(Transaction txn, Environment env, String dbName, DatabaseConfig dbConfig, EntityModel modelParam, Mutations mutationsParam, boolean useCurrentModel)
          Creates a new catalog, opening the database and reading it from a given catalog database if it already exists.
 
Method Summary
 boolean close()
          Decrements the reference count and closes the catalog DB when it reaches zero.
 Format createFormat(Class type, Map<String,Format> newFormats)
          If the given class format is not already present in the given map, creates an uninitialized format, adds it to the map, and also collects related formats in the map.
 Format getFormat(Class cls)
          Returns a format for a given class, or throws an exception.
 Format getFormat(int formatId)
          Returns a format for a given ID, or throws an exception.
 Format getFormat(String className)
          Returns a format by class name.
(package private)  Set<String> getModelClasses()
          Returns a set of all persistent (non-simple type) class names.
 Mutations getMutations()
          Returns the current merged mutations.
 EntityModel getResolvedModel()
          Gets the model parameter, default model or stored model.
 void openExisting()
          Increments the reference count for a catalog that is already open.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistCatalog

public PersistCatalog(Transaction txn,
                      Environment env,
                      String dbName,
                      DatabaseConfig dbConfig,
                      EntityModel modelParam,
                      Mutations mutationsParam,
                      boolean useCurrentModel)
               throws DatabaseException
Creates a new catalog, opening the database and reading it from a given catalog database if it already exists. All predefined formats and formats for the given model are added. For modified classes, old formats are defined based on the rules for compatible class changes and the given mutations. If any format is changed or added, and the database is not read-only, write the initialized catalog to the database.

Throws:
DatabaseException
Method Detail

getResolvedModel

public EntityModel getResolvedModel()
Gets the model parameter, default model or stored model.


openExisting

public void openExisting()
Increments the reference count for a catalog that is already open.


close

public boolean close()
              throws DatabaseException
Decrements the reference count and closes the catalog DB when it reaches zero. Returns true if the database was closed or false if the reference count is still non-zero and the database was left open.

Throws:
DatabaseException

getMutations

public Mutations getMutations()
Returns the current merged mutations.


createFormat

public Format createFormat(Class type,
                           Map<String,Format> newFormats)
If the given class format is not already present in the given map, creates an uninitialized format, adds it to the map, and also collects related formats in the map.

Specified by:
createFormat in interface Catalog
See Also:
createFormat(java.lang.Class, java.util.Map)

getModelClasses

Set<String> getModelClasses()
Returns a set of all persistent (non-simple type) class names.


getFormat

public Format getFormat(int formatId)
Description copied from interface: Catalog
Returns a format for a given ID, or throws an exception. This method is used when reading an object from the byte array format.

Specified by:
getFormat in interface Catalog

getFormat

public Format getFormat(Class cls)
Description copied from interface: Catalog
Returns a format for a given class, or throws an exception. This method is used when writing an object that was passed in by the user.

Specified by:
getFormat in interface Catalog

getFormat

public Format getFormat(String className)
Description copied from interface: Catalog
Returns a format by class name. Unlike Catalog.getFormat(int), the format will not be created if it is not already known.

Specified by:
getFormat in interface Catalog


Copyright 2004-2006 Sleepycat, Inc. All Rights Reserved.