blackboard.persist
Class DatabaseContainer

java.lang.Object
  extended by blackboard.persist.DatabaseContainer
All Implemented Interfaces:
Container

public class DatabaseContainer
extends java.lang.Object
implements Container

The DatabaseContainer class implements the Container interface for a database. It therefore represents the information necessary for allowing the persistence framework to operate against a database.

Since:
Bb 5.5
Version:
$Revision: #1 $ $Date: 2005/06/27 $

Constructor Summary
DatabaseContainer(BbDatabase bbDatabase)
          Constructor - creates a new DatabaseContainer object with the given BbDatabase used to define the specifics of the data source.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 Id generateId(DataType dataType, int nKey1)
          Generates an Id instance specific to this DatabaseContainer .
 Id generateId(DataType dataType, int nKey1, int nKey2)
          Generates an Id instance specific to this DatabaseContainer .
 Id generateId(DataType dataType, java.lang.String strKey)
          Generates an Id instance specific to this DatabaseContainer.
 AppVersion getAppVersion()
          Return the AppVersion associated with this DatabaseContainer.
 BbDatabase getBbDatabase()
          Returns the BbDatabase associated with this DatabaseContainer.
static DatabaseContainer getDefaultInstance()
          Returns the default DatabaseContainer for the system.
 int hashCode()
           
 boolean isValidId(Id id)
          Determines if the provided Id is a "valid" id for this DatabaseContainer.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseContainer

public DatabaseContainer(BbDatabase bbDatabase)
Constructor - creates a new DatabaseContainer object with the given BbDatabase used to define the specifics of the data source.

Parameters:
bbDatabase - the BbDatabase to use in configuring this container and the data source is should represent
Throws:
java.lang.NullPointerException - if database is null
Method Detail

getAppVersion

public AppVersion getAppVersion()
Return the AppVersion associated with this DatabaseContainer. The AppVersion returned is that contained within the BbDatabase provided at initialization time. This AppVersion serves as a default AppVersion for subsequent calls into the persistence framework.

Specified by:
getAppVersion in interface Container
Returns:
the AppVersion defined for this container

getBbDatabase

public BbDatabase getBbDatabase()
Returns the BbDatabase associated with this DatabaseContainer.

Returns:
the BbDatabase associated with this database container

getDefaultInstance

public static DatabaseContainer getDefaultInstance()
Returns the default DatabaseContainer for the system. This container represents a database container instance configured to use the default database connection information.

Returns:
the default DatabaseContainer as defined based upon the default database configuration

generateId

public Id generateId(DataType dataType,
                     java.lang.String strKey)
              throws PersistenceException
Generates an Id instance specific to this DatabaseContainer. The format of the provided string key value should be the same as that generated by PkId.toExternalString().

Specified by:
generateId in interface Container
Parameters:
dataType - the DataType of the object that the generated Id instance will refer to
strKey - the String value to use when generating the key value of the Id instance. Should be of tha same from as generated by PkId.toExternalString()
Returns:
an Id implementation instance, appropriate to this DatabaseContainer, whose key value is generated from the given value
Throws:
PersistenceException - if an error occurs in the Id generation process
See Also:
PkId.toExternalString()

generateId

public Id generateId(DataType dataType,
                     int nKey1,
                     int nKey2)
              throws PersistenceException
Generates an Id instance specific to this DatabaseContainer . The value of the provided integers does not matter, but, the combination of the two values should be unique in order for the generated Id itself to be unique.

Specified by:
generateId in interface Container
Parameters:
dataType - the DataType of the object that the generated Id instance will refer to
nKey1 - an integer value to use when generating the key value of the Id instance
nKey2 - another integer value to use when generating the key value of the Id instance
Returns:
an Id implementation instance, appropriate to this DatabaseContainer, whose key value is generated from the given integer values
Throws:
PersistenceException - if an error occurs in the Id generation process

generateId

public Id generateId(DataType dataType,
                     int nKey1)
              throws PersistenceException
Generates an Id instance specific to this DatabaseContainer . The value of the provided integers does not matter, but, the combination of the two values should be unique in order for the generated Id itself to be unique.

Specified by:
generateId in interface Container
Parameters:
dataType - the DataType of the object that the generated Id instance will refer to
nKey1 - an integer value to use when generating the key value of the Id instance
Returns:
an Id implementation instance, appropriate to this DatabaseContainer, whose key value is generated from the given integer values
Throws:
PersistenceException - if an error occurs in the Id generation process

isValidId

public boolean isValidId(Id id)
Determines if the provided Id is a "valid" id for this DatabaseContainer.

An Id is considered valid for this DatabaseContainer if it is "set" (see Id.isSet()), if it originates from this database container, and if it is an instance of the appropriate Id subclass for this database container.

Specified by:
isValidId in interface Container
Parameters:
id - the Id to examine for validity
Returns:
true is the provided id is a valid id for this database container, false otherwise

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object


Copyright © 2003 Blackboard, Inc. All Rights Reserved.