public class Catalog
extends java.lang.Object
Constructor and Description |
---|
Catalog(java.lang.String catalogFile)
Construct a new catalog given the name of the catalog file.
|
Modifier and Type | Method and Description |
---|---|
void |
createNewEntry(CatalogEntry entry)
Creates an entry into the catalog for a new table.
|
void |
deleteTable(java.lang.String tablename)
Deletes a table from the catalog.
|
Table |
getTable(java.lang.String tableName)
Returns the table associated with a table name.
|
java.lang.String |
getTableFileName(java.lang.String tableName)
Returns the name of the file associated with a table.
|
static void |
main(java.lang.String[] args)
Debug main()
|
void |
readCatalog()
Reads in the catalog from the file specified by the filename
passed as an argument to the constructor.
|
protected boolean |
tableExists(java.lang.String tableName)
Checks to see whether the given table exists in the catalog.
|
java.lang.String |
toString()
Returns the string representation of this catalog.
|
void |
writeCatalog()
Writes the catalog into the specified file specified by the
filename passed as an argument to the constructor.
|
public Catalog(java.lang.String catalogFile)
catalogFile
- the name of the catalog file.public void createNewEntry(CatalogEntry entry) throws java.lang.IllegalArgumentException
entry
- the catalog entry for the new catalog.java.lang.IllegalArgumentException
- thrown whenever the user
tries to create a table with the same name as an existing one.protected boolean tableExists(java.lang.String tableName)
tableName
- the name of the table to be checked.trueif the table exists,
falseotherwise.
public void readCatalog() throws StorageManagerException
StorageManagerException
- thrown whenever there is
something wrong with reading the catalog filepublic void writeCatalog() throws StorageManagerException
StorageManagerException
- thrown whenever there is
something wrong with writing out the catalog file.public java.lang.String getTableFileName(java.lang.String tableName) throws java.util.NoSuchElementException
tableName
- the table name.java.util.NoSuchElementException
- if a table with the given file
name does not exist in the catalog.public Table getTable(java.lang.String tableName) throws java.util.NoSuchElementException
tableName
- the table namejava.util.NoSuchElementException
- whenever the given table does
not exist.public void deleteTable(java.lang.String tablename) throws java.util.NoSuchElementException
tablename
- the name of the table to be deleted.java.util.NoSuchElementException
- thrown if the table is not in
the catalog.public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args)