public class DB extends DBLineParsers
Constructor and Description |
---|
DB(java.lang.String name,
DBSchema schema)
Create an empty database with a given name and DBSchema type
|
Modifier and Type | Method and Description |
---|---|
boolean |
containsTable(java.lang.String tableName)
Returns true if there is a table with tableName in the database
|
void |
deleteAll()
delete all tuples in the database
|
boolean |
equals(DB other)
does 'this' database equal another database
|
java.lang.String |
getFullName()
the "full" name of a database is "databaseName"."schemaName"."pl";
|
java.lang.String |
getName()
returns the name of this database
|
DBSchema |
getSchema()
returns DBSchema that this database instantiates
|
java.lang.String |
getSchemaName()
returns name of 'this' DBSchema
|
SubTableSchema |
getSubTableSchema(TableSchema ts)
returns subtable declaration for a given table schema ts; if no such
declaration exists, null is returned; this declaration lists the
subtables of the given table.
|
java.util.List<SubTableSchema> |
getSubTableSchemas()
returns a list of subtable declarations for this database's schema.
|
Table |
getTable(java.lang.String tableName)
returns the Table object for the table with SubTableSchema tableName;
null is returned if table does not exist
|
Table |
getTableEH(java.lang.String tableName)
error handler of getTable(String); return the Table object for the table
with SubTableSchema tableName; Error is thrown if no such table exists.
|
java.util.Collection<Table> |
getTables()
returns a collection of tables that define this database
|
TableSchema |
getTableSchema(java.lang.String name)
returns the TableSchema of the table with given SubTableSchema; null if
table is not found
|
TableSchema |
getTableSchemaEH(java.lang.String name)
returns the TableSchema of the table with given SubTableSchema; Error is
thrown otherwise
|
void |
print()
print DB to System.out
|
void |
print(java.io.PrintStream out)
print the database to PrintStream out;
typically used for demonstrations as it doesn't check the
format of the filename.
|
void |
print(java.lang.String filename)
print database in file with filename
|
static DB |
readDataBase(java.io.File infile)
reads and parses a database from given string filename.
|
static DB |
readDataBase(java.lang.String localFileName)
reads and parses a prolog database from given string filename.
|
void |
rename(java.lang.String name)
assigns a new SubTableSchema to this database
|
parseDBaseDecl, parseSubTableDecl, parseTableDecl, parseTableDecl, parseTupleDecl
public DB(java.lang.String name, DBSchema schema)
name
- of the databaseschema
- of the databasepublic static DB readDataBase(java.lang.String localFileName)
localFileName
- is the SubTableSchema of the file of the Prolog
databasepublic static DB readDataBase(java.io.File infile)
infile
- is the File of the Prolog databasepublic java.lang.String getName()
public java.lang.String getFullName()
public DBSchema getSchema()
public java.lang.String getSchemaName()
public java.util.List<SubTableSchema> getSubTableSchemas()
public SubTableSchema getSubTableSchema(TableSchema ts)
ts
- -- table schema for which subtable declaration is to be
returnedpublic java.util.Collection<Table> getTables()
public Table getTable(java.lang.String tableName)
tableName
- -- SubTableSchema of table to returnpublic Table getTableEH(java.lang.String tableName)
tableName
- -- SubTableSchema of table to returnpublic TableSchema getTableSchema(java.lang.String name)
name
- SubTableSchema of desired tablepublic TableSchema getTableSchemaEH(java.lang.String name)
name
- SubTableSchema of desired tablepublic void deleteAll()
public boolean equals(DB other)
other
- databasepublic boolean containsTable(java.lang.String tableName)
tableName
- of tablepublic void rename(java.lang.String name)
name
- new SubTableSchemapublic void print(java.io.PrintStream out)
out
- PrintStream destinationpublic void print()
public void print(java.lang.String filename)
filename
- -- name of file in which to print database