Class TableDescriptions


  • public final class TableDescriptions
    extends java.lang.Object
    An 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.File backup_file
      The backup file for table descriptions.
      private java.io.File table_desc_file
      The File that contains the table descriptions list.
      private static java.lang.String TABLE_DESC_FILE
      The filename of the file that describes every table in the database.
      private java.util.HashMap table_descriptions
      A hash table that maps from table name to the DataTableDef object that describes the table.
      private java.io.File temp_desc_file
      The 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) void add​(DataTableDef table)
      Adds a new DataTableDef object to the list of tables in the database.
      (package private) void clear()
      Clears this object completely.
      boolean exists()
      Returns true if the table descriptions file exists.
      DataTableDef getDef​(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.
      void load()
      Load the entire list of table descriptions for this database.
      (package private) void remove​(java.lang.String name)
      Removes a DataTableDef object from the list with the given name.
      void save()
      Updates the table description file in the database.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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.
    • Constructor Detail

      • TableDescriptions

        public TableDescriptions​(java.io.File database_path)
        Constructs this object with the database in the given directory.
    • Method Detail

      • exists

        public boolean exists()
        Returns true if the table descriptions file exists.
      • load

        public void load()
                  throws java.io.IOException
        Load the entire list of table descriptions for this database.
        Throws:
        java.io.IOException
      • save

        public void save()
                  throws java.io.IOException
        Updates 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.IOException
        Removes 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.