Package com.mckoi.database
Class TableDescriptions
- java.lang.Object
-
- com.mckoi.database.TableDescriptions
-
public final class TableDescriptions extends java.lang.ObjectAn object that is a key part of Database. This object maintains a list of descriptions of all tables in the database. The list contains information about the columns in the table and any other misc table options.
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.Filebackup_fileThe backup file for table descriptions.private java.io.Filetable_desc_fileThe File that contains the table descriptions list.private static java.lang.StringTABLE_DESC_FILEThe filename of the file that describes every table in the database.private java.util.HashMaptable_descriptionsA hash table that maps from table name to the DataTableDef object that describes the table.private java.io.Filetemp_desc_fileThe File we use to temporary store the table descriptions as we save them.
-
Constructor Summary
Constructors Constructor Description TableDescriptions(java.io.File database_path)Constructs this object with the database in the given directory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidadd(DataTableDef table)Adds a new DataTableDef object to the list of tables in the database.(package private) voidclear()Clears this object completely.booleanexists()Returns true if the table descriptions file exists.DataTableDefgetDef(java.lang.String table_name)Returns the DataTableDef object for the table with the given name.java.lang.String[]getTableList()Returns a list of table name's sorted in alphebetical order.voidload()Load the entire list of table descriptions for this database.(package private) voidremove(java.lang.String name)Removes a DataTableDef object from the list with the given name.voidsave()Updates the table description file in the database.
-
-
-
Field Detail
-
TABLE_DESC_FILE
private static final java.lang.String TABLE_DESC_FILE
The filename of the file that describes every table in the database.- See Also:
- Constant Field Values
-
table_desc_file
private java.io.File table_desc_file
The File that contains the table descriptions list.
-
temp_desc_file
private java.io.File temp_desc_file
The File we use to temporary store the table descriptions as we save them.
-
backup_file
private java.io.File backup_file
The backup file for table descriptions.
-
table_descriptions
private java.util.HashMap table_descriptions
A hash table that maps from table name to the DataTableDef object that describes the table.
-
-
Method Detail
-
exists
public boolean exists()
Returns true if the table descriptions file exists.
-
load
public void load() throws java.io.IOExceptionLoad the entire list of table descriptions for this database.- Throws:
java.io.IOException
-
save
public void save() throws java.io.IOExceptionUpdates the table description file in the database. The table description file describes every table in the database. It is loaded when the database is initialized and refreshed whenever a table alteration occurs or the database is shut down.- Throws:
java.io.IOException
-
add
void add(DataTableDef table) throws java.io.IOException
Adds a new DataTableDef object to the list of tables in the database.- Throws:
java.io.IOException
-
remove
void remove(java.lang.String name) throws java.io.IOExceptionRemoves a DataTableDef object from the list with the given name.- Throws:
java.io.IOException
-
getTableList
public java.lang.String[] getTableList()
Returns a list of table name's sorted in alphebetical order.
-
clear
void clear()
Clears this object completely.
-
getDef
public DataTableDef getDef(java.lang.String table_name)
Returns the DataTableDef object for the table with the given name. The description must have been loaded before this method is called. Returns null if the table was not found.
-
-