Package com.mckoi.database.control
Class DBController
- java.lang.Object
-
- com.mckoi.database.control.DBController
-
public final class DBController extends java.lang.ObjectAn object that provides methods for creating and controlling database systems in the current JVM.
-
-
Field Summary
Fields Modifier and Type Field Description private static DBControllerVM_DB_CONTROLLERThe static DBController object.
-
Constructor Summary
Constructors Constructor Description DBController()This object can not be constructed outside of this package.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static DatabasecreateDatabase(DBConfig config)Creates a Database object for the given DBConfig configuration.DBSystemcreateDatabase(DBConfig config, java.lang.String admin_user, java.lang.String admin_pass)Creates a database in the local JVM (and filesystem) given the configuration in DBConfig and returns a DBSystem object.booleandatabaseExists(DBConfig config)Returns true if a Mckoi database exists in the given directory of the file system, otherwise returns false if the path doesn't contain a database.static DBControllergetDefault()Returns the static controller for this JVM.DBSystemstartDatabase(DBConfig config)Starts a database in the local JVM given the configuration in DBConfig and returns a DBSystem object.
-
-
-
Field Detail
-
VM_DB_CONTROLLER
private static final DBController VM_DB_CONTROLLER
The static DBController object.
-
-
Method Detail
-
databaseExists
public boolean databaseExists(DBConfig config)
Returns true if a Mckoi database exists in the given directory of the file system, otherwise returns false if the path doesn't contain a database.The path string must be formatted using Unix '/' deliminators as directory separators.
- Parameters:
config- the configuration of the database to check the existence of.- Returns:
- true if a database exists at the given path, false otherwise.
-
createDatabase
public DBSystem createDatabase(DBConfig config, java.lang.String admin_user, java.lang.String admin_pass)
Creates a database in the local JVM (and filesystem) given the configuration in DBConfig and returns a DBSystem object. When this method returns, the database created will be up and running providing there was no failure during the database creation process.A failure might happen because the database path does not exist.
- Parameters:
admin_user- the username of the administrator for the new database.admin_pass- the password of the administrator for the new database.config- the configuration of the database to create and start in the local JVM.- Returns:
- the DBSystem object used to access the database created.
-
startDatabase
public DBSystem startDatabase(DBConfig config)
Starts a database in the local JVM given the configuration in DBConfig and returns a DBSystem object. When this method returns, the database will be up and running providing there was no failure to initialize the database.A failure might happen if the database does not exist in the path given in the configuration.
- Parameters:
config- the configuration of the database to start in the local JVM.- Returns:
- the DBSystem object used to access the database started.
-
createDatabase
private static Database createDatabase(DBConfig config)
Creates a Database object for the given DBConfig configuration.
-
getDefault
public static DBController getDefault()
Returns the static controller for this JVM.
-
-