TemporaryDatabase
Class Manager

java.lang.Object
  |
  +--TemporaryDatabase.Manager
All Implemented Interfaces:
DatabaseManager

public class Manager
extends Object
implements DatabaseManager

Database for storage of temporary (in memory) tables.

Author:
chris.studholme@utoronto.ca

Field Summary
private static int majorVersion
           
private static int minorVersion
           
private static String pkg
           
private  ArrayList tables
           
 
Constructor Summary
Manager()
           
 
Method Summary
 boolean createIndex(String name, String column)
          Create an index of the specified column in the specified table (if capable).
 DatabaseTable createTable(String name, boolean temporary)
          Create a new table.
 boolean dropIndex(String name, String column)
          Drop an index.
 void dropTable(String name)
          Drop a table.
 Function getFunction(String function_name)
          Get a database specific function for use in SQL.
 int getMajorVersion()
          Get the driver's major version number.
 int getMinorVersion()
          Get the driver's minor version number.
 boolean hasTable(String name)
          Checks whether this database has the specified table.
 DatabaseTable openTable(String name)
          Opens the database table with the specified name for read only access.
 DatabaseTable openTable(String name, boolean readonly)
          Opens the database table with the specified name with read only or read write access.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

majorVersion

private static final int majorVersion

minorVersion

private static final int minorVersion

pkg

private static final String pkg

tables

private ArrayList tables
Constructor Detail

Manager

public Manager()
Method Detail

getMajorVersion

public int getMajorVersion()
Description copied from interface: DatabaseManager
Get the driver's major version number. Initially this should be 1.
Specified by:
getMajorVersion in interface DatabaseManager
Following copied from interface: ModSQL.DatabaseManager
Returns:
major version number

getMinorVersion

public int getMinorVersion()
Description copied from interface: DatabaseManager
Get the driver's minor version number. Initially this should be 0.
Specified by:
getMinorVersion in interface DatabaseManager
Following copied from interface: ModSQL.DatabaseManager
Returns:
minor version number

hasTable

public boolean hasTable(String name)
Description copied from interface: DatabaseManager
Checks whether this database has the specified table.
Specified by:
hasTable in interface DatabaseManager
Following copied from interface: ModSQL.DatabaseManager
Parameters:
tablename - name of the table
Returns:
true if the table exists in this database and can be opened, false otherwise
Throws:
DatabaseException - if a database-access error occurs

openTable

public DatabaseTable openTable(String name,
                               boolean readonly)
                        throws DatabaseException
Description copied from interface: DatabaseManager
Opens the database table with the specified name with read only or read write access.
Specified by:
openTable in interface DatabaseManager
Following copied from interface: ModSQL.DatabaseManager
Parameters:
tablename - name of the table to open
readonly - true to open table read only
Returns:
a DatabaseTable object representing the table, or null if the table does not exist in this database
Throws:
DatabaseException - if a database-access error occurs

openTable

public DatabaseTable openTable(String name)
                        throws DatabaseException
Description copied from interface: DatabaseManager
Opens the database table with the specified name for read only access.
Specified by:
openTable in interface DatabaseManager
Following copied from interface: ModSQL.DatabaseManager
Parameters:
tablename - name of the table to open
Returns:
a DatabaseTable object representing the table, or null if the table does not exist in this database
Throws:
DatabaseException - if a database-access error occurs

createTable

public DatabaseTable createTable(String name,
                                 boolean temporary)
                          throws DatabaseException
Description copied from interface: DatabaseManager
Create a new table. If a table with the given name exists in the database, this method should always throw an exception. If the database is not capable of supporting user created tables, this method should return null.
Specified by:
createTable in interface DatabaseManager
Following copied from interface: ModSQL.DatabaseManager
Parameters:
tablename - name of the table to create
temporary - table is temporary
Returns:
the newly created table opened for read write access, or null if the database doesn't support creating tables
Throws:
DatabaseException - if a database-access error occurs

dropTable

public void dropTable(String name)
               throws DatabaseException
Description copied from interface: DatabaseManager
Drop a table. This method should throw an exception if the table does not exist.
Specified by:
dropTable in interface DatabaseManager
Following copied from interface: ModSQL.DatabaseManager
Parameters:
tablename - name of the table to drop
Throws:
DatabaseException - if a database-access error occurs

createIndex

public boolean createIndex(String name,
                           String column)
Description copied from interface: DatabaseManager
Create an index of the specified column in the specified table (if capable).
Specified by:
createIndex in interface DatabaseManager
Following copied from interface: ModSQL.DatabaseManager
Parameters:
tablename - name of the table to index
columnname - name of the column to index
Returns:
true if index was created, false if database is not capable of creating indicies
Throws:
DatabaseException - if a database-access error occurs

dropIndex

public boolean dropIndex(String name,
                         String column)
                  throws DatabaseException
Description copied from interface: DatabaseManager
Drop an index. This method should throw an exception if the table does not exist, but should return false if the column has not been indexed.
Specified by:
dropIndex in interface DatabaseManager
Following copied from interface: ModSQL.DatabaseManager
Parameters:
tablename - name of the table with index
columnname - name of the column with index
Returns:
true if the index existed and has been dropped, false if it didn't exist
Throws:
DatabaseException - if a database-access error occurs

getFunction

public Function getFunction(String function_name)
Description copied from interface: DatabaseManager

Get a database specific function for use in SQL. This function may be used in any SQL query (not just queries involving this database's tables). Note that when looking up function names, ModSQL will always check for database specific functions before using built-in functions, so this method may be used to override the built-in SQL functions.

This method should return null if a function by the specified name is not found.

Specified by:
getFunction in interface DatabaseManager
Following copied from interface: ModSQL.DatabaseManager
Parameters:
name - name of function to lookup (always lowercase)
Returns:
new function object (or null if function not found)
Throws:
DatabaseException - if a database-access error occurs