public class TableSchema
extends java.lang.Object
Constructor and Description |
---|
TableSchema(java.lang.String name)
create table schema with given schemaName and an empty list of columns
|
TableSchema(java.lang.String name,
java.util.List<Column> cols)
create table schema with given schemaName and given set of columns
|
Modifier and Type | Method and Description |
---|---|
void |
addColumn(Column c)
add a new column c to 'this' TableSchema; new column is appended to the
existing list of columns
Error is thrown if columns with duplicate names are detected
|
void |
addColumnFirst(Column c)
add column c as the first of 'this' schema
|
void |
addColumns(Column... columns)
append an array of column to existing columns of 'this' schema
|
void |
addColumnsFirst(Column... columns)
place an array of columns before existing columns of 'this' schema
|
TableSchema |
CopyForSelfJoins(java.lang.String newTableName)
copies table schema (this) for self-joins.
|
TableSchema |
crossProduct(TableSchema otherSchema)
form the cross product of 'this' schema with otherSchema; this is a
concatenation of the column lists and a manufactured table name
|
boolean |
equals(TableSchema otherSchema)
returns true if 'this' schema equals otherSchema, false otherwise
|
void |
equalsEH(TableSchema otherSchema)
asserts if 'this' schema == otherSchema If false, Error is thrown
|
Column |
getColumn(java.lang.String name) |
Column |
getColumnEH(java.lang.String name) |
java.util.List<Column> |
getColumns()
returns list of columns of a TableSchema
|
Column |
getIndex(int i)
returns the ith Column definition of the table; throws RuntimeError if i
is out of bounds.
|
java.lang.String |
getName()
returns schemaName of table schema
|
boolean |
isDetached() |
void |
print(java.io.PrintStream out)
print 'this' TableSchema to PrintStream out
|
static TableSchema |
readSchema(java.io.File schemafile)
reads prolog schema from File schemafile; errors are reported to out
read only .schema and database files
|
static TableSchema |
readSchema(java.lang.String schemafileName)
reads prolog schema from File schemafileName that contains a single table
declaration; ParseExceptions and Errors are thrown
read only .schema and database files
|
int |
size()
returns number of columns presently in 'this' TableSchema
|
java.lang.String |
toString()
returns string declaration of a TableSchema
|
public TableSchema(java.lang.String name)
name
- of new TableSchemapublic TableSchema(java.lang.String name, java.util.List<Column> cols)
name
- of new TableScheamcols
- is list of column declarationspublic java.lang.String getName()
public Column getIndex(int i)
i
- column indexpublic java.util.List<Column> getColumns()
public int size()
public boolean isDetached()
public TableSchema CopyForSelfJoins(java.lang.String newTableName)
newTableName
- -- string to newTableName to give a different name to
copypublic static TableSchema readSchema(java.lang.String schemafileName)
schemafileName
- name of the file that contains a single Table
declarationpublic static TableSchema readSchema(java.io.File schemafile)
schemafile
- Java File of schema file to read (can also be a
database file, as it too embeds schema information)public TableSchema crossProduct(TableSchema otherSchema)
otherSchema
- -- to form cross productpublic void addColumn(Column c)
c
- is column to addpublic void addColumnFirst(Column c)
c
- column to addpublic void addColumns(Column... columns)
columns
- is array of columns to addpublic void addColumnsFirst(Column... columns)
columns
- is array of columns to addpublic void equalsEH(TableSchema otherSchema)
otherSchema
- -- the schema to compare topublic boolean equals(TableSchema otherSchema)
otherSchema
- -- other schema to comparepublic Column getColumnEH(java.lang.String name)
name
- of column to findLocalpublic Column getColumn(java.lang.String name)
name
- of columnpublic java.lang.String toString()
toString
in class java.lang.Object
public void print(java.io.PrintStream out)
out
- where to print