public class DBSchema extends Parser
Constructor and Description |
---|
DBSchema(java.lang.String name)
This constructor is used for the incremental construction of database
tableSchemas.
|
DBSchema(java.lang.String name,
TableSchema... schemas)
create DBSchema that has name and a list of TableSchemas can
incrementally add subtable tableSchemas subsequently -- before schema is
instantiated as a database
|
Modifier and Type | Method and Description |
---|---|
void |
addSubTableSchema(SubTableSchema sts)
add subtable schema sts to 'this' database schema
|
void |
addTableSchema(TableSchema tableschema)
add table schema tableschema to 'this' database schema
|
static void |
anyschemaCheck(java.lang.String schemaFileName)
asserts that schemaFileName, which could be an .ooschema or .schema, ends
with the appropriate ".schema.pl" or ".ooschema.pl" extensions, otherwise
a Error is thrown
|
DBSchema |
copy()
copy a database schema -- please do not alter existing table definitions
and subtable definitions.
|
boolean |
equals(DBSchema dbschema)
two DBSchemas are equal iff (a) they have the same name, (b) they have
the same set of table schemas, and (c) they have the same set of
subtableschemas; if so true is returned.
|
void |
equalsEH(DBSchema dbschema)
two DBSchemas are equal iff (a) they have the same name, (b) they have
the same set of table schemas, and (c) they have the same set of sub
table schemas; if so this method returns.
|
void |
flatten()
propagate attributes of superTables to subTables (operation is performed
on schema defs)
|
java.lang.String |
getFullName()
full (file) name of a schema is (name).schema.pl
|
java.lang.String |
getName()
return the name of the schema
|
SubTableSchema |
getSubTableSchema(java.lang.String tableName)
returns subtable object for given tableName, null if none exists
|
SubTableSchema |
getSubTableSchema(TableSchema ts)
returns subtable object for given tableSchema ts, null if none exists
|
SubTableSchema |
getSubTableSchemaEH(java.lang.String tableName)
returns subtable object for given tableName; throws Error if no
such tableName exists
|
SubTableSchema |
getSubTableSchemaEH(TableSchema ts)
returns subtable object for given tableSchema ts; throws Error
if no such ts exists
|
java.util.LinkedList<SubTableSchema> |
getSubTableSchemas()
return list of SubTableSchemas of this database schema
|
TableSchema |
getTableSchema(java.lang.String tableName)
return the TableSchema with name tableName
|
TableSchema |
getTableSchemaEH(java.lang.String tableName)
return the TableSchema with name tableName
|
java.util.LinkedList<TableSchema> |
getTableSchemas()
return list of TableSchemas of this database schema
|
void |
print(java.io.PrintStream out)
print the database schema definition to PrintStream out; works for
ooschemas and schema files
|
static DBSchema |
readSchema(java.io.File schemafile,
java.io.PrintStream out)
reads prolog schema from File schemafile; errors are reported to out
can read .ooschema and .schema files
|
static DBSchema |
readSchema(java.lang.String schemafile)
reads .ooschema and .schema files; throws Error when an error is
encountered.
|
void |
rename(java.lang.String name)
rename DBschema
|
static void |
schemaCheck(java.lang.String schemaFileName)
asserts that schemaFilename must end with ".schema.pl"; throws
Error otherwise
|
int |
size()
return number of TableSchemas (equivalently the number of Tables in a
schema instance) in this dbschema
|
java.lang.String |
toString()
converts DBSchema to a string.
|
parseDBaseDecl, parseSubTableDecl, parseTableDecl, parseTableDecl, parseTupleDecl
public DBSchema(java.lang.String name, TableSchema... schemas)
name
- of DBSchemaschemas
- comma-separated list of table tableSchemaspublic DBSchema(java.lang.String name)
name
- -- name given to the DBSchemapublic java.lang.String getName()
public java.lang.String getFullName()
public java.util.LinkedList<TableSchema> getTableSchemas()
public java.util.LinkedList<SubTableSchema> getSubTableSchemas()
public SubTableSchema getSubTableSchema(java.lang.String tableName)
tableName
- -- name of table whose subtables are to be returnedpublic SubTableSchema getSubTableSchemaEH(java.lang.String tableName)
tableName
- -- name of table whose subtables are to be returnedpublic SubTableSchema getSubTableSchema(TableSchema ts)
ts
- -- TableSchema object for which subtable declaration is to be returnedpublic SubTableSchema getSubTableSchemaEH(TableSchema ts)
ts
- -- name of tableSchema whose subtables are to be returnedpublic int size()
public DBSchema copy()
public static DBSchema readSchema(java.lang.String schemafile)
schemafile
- -- name of schema filepublic static DBSchema readSchema(java.io.File schemafile, java.io.PrintStream out)
schemafile
- Java File of schema file to read (can also be a
database file, as it too embeds schema information)out
- PrintStream to report errorspublic void addTableSchema(TableSchema tableschema)
tableschema
- to add to 'this' database schemapublic void addSubTableSchema(SubTableSchema sts)
sts
- subtableschema to add to 'this' databasepublic TableSchema getTableSchema(java.lang.String tableName)
tableName
- of schema to returnpublic TableSchema getTableSchemaEH(java.lang.String tableName)
tableName
- of schema to returnpublic static void schemaCheck(java.lang.String schemaFileName)
schemaFileName
- -- file name to qualifypublic static void anyschemaCheck(java.lang.String schemaFileName)
schemaFileName
- -- name of schema file to checkpublic boolean equals(DBSchema dbschema)
dbschema
- -- the other dbschemapublic void equalsEH(DBSchema dbschema)
dbschema.
- public void rename(java.lang.String name)
name
- new DBSchema namepublic void flatten()
public java.lang.String toString()
toString
in class java.lang.Object
public void print(java.io.PrintStream out)
out
- PrintStream destination