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
|
TableSchema(java.lang.String name,
java.lang.String... cnames)
create table schema with given schemaName and given set of columns
|
| Modifier and Type | Method and Description |
|---|---|
TableSchema |
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
|
TableSchema |
addColumn(java.lang.String k)
adds a column whose name/type is encoded by k
|
TableSchema |
addColumnFirst(Column c)
add column c as the first of 'this' schema
|
TableSchema |
addColumnFirst(java.lang.String k)
adds a column to the head of the list of columns
|
TableSchema |
addColumns(java.lang.String... columns)
adds a sequence of columns
|
TableSchema |
addColumnsFirst(Column... columns)
place an array of columns before existing columns of 'this' schema
|
TableSchema |
addColumnsFirst(java.lang.String... columns)
add list of columns to the head of a 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
plus the addition of an id field as first attribute
|
void |
doesNotHaveColumnEH(java.lang.String columnName)
does schema NOT have a column with columnName?
|
boolean |
equals(TableSchema otherSchema)
returns true if 'this' schema equals otherSchema, false otherwise
equality is based on the same number and sequence of columns
|
void |
equalsEH(TableSchema otherSchema)
asserts if 'this' schema == otherSchema If false, Error is thrown
equality is based on the same number and set of columns
|
Column |
getColumn(int i)
returns the ith Column definition of the table; throws RuntimeError if i
is out of bounds.
|
Column |
getColumn(java.lang.String name) |
Column |
getColumnEH(java.lang.String name) |
java.util.List<Column> |
getColumns()
returns list of columns of a TableSchema
|
java.lang.String |
getIDName() |
java.lang.String |
getName() |
TableSchema |
getSuperTableOf()
gets supertable of table schema s; throws Error if 'this' table schema
not part of a database
|
void |
hasColumnEH(java.lang.String columnName)
does schema have a column with columnName?
|
boolean |
isDetached() |
boolean |
isSuperTableOf(TableSchema s)
is 'this' schema a supertable (ancestor) of table schema s?
|
void |
print()
print to System.out
|
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 schema from File schemafileName that contains a single table
declaration; ParseExceptions and Errors are thrown
read only .schema and database files
|
static TableSchema |
readSchema(java.lang.String nameOfSchema,
java.lang.String stringDefOfSchema)
used when it is easier to pass in a string declaration of a TableSchema
rather than building it programmatically
|
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 TableSchema(java.lang.String name,
java.lang.String... cnames)
name - of new TableScheamcnames - is list of column names,public java.lang.String getName()
public Column getColumn(int i)
i - column indexpublic java.lang.String getIDName()
public java.util.List<Column> getColumns()
public void hasColumnEH(java.lang.String columnName)
columnName - -- column name to verify existencepublic void doesNotHaveColumnEH(java.lang.String columnName)
columnName - -- column name to verify nonexistencepublic 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 static TableSchema readSchema(java.lang.String nameOfSchema, java.lang.String stringDefOfSchema)
nameOfSchema - -- name of pseudo filestringDefOfSchema - -- string (multi line typically) contents of pseudo filepublic TableSchema crossProduct(TableSchema otherSchema)
otherSchema - -- to form cross productpublic TableSchema addColumn(Column c)
c - is column to addpublic TableSchema addColumnFirst(Column c)
c - column to addpublic TableSchema addColumn(java.lang.String k)
k - -- either an identifier or 'identifier'public TableSchema addColumnFirst(java.lang.String k)
k - -- either an identifier or 'identifier'public TableSchema addColumns(java.lang.String... columns)
columns - -- sequence of column-encoded namespublic TableSchema addColumnsFirst(java.lang.String... columns)
columns - -- encoded names of columns to addpublic TableSchema 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.Objectpublic void print(java.io.PrintStream out)
out - where to printpublic void print()
public TableSchema getSuperTableOf()
public boolean isSuperTableOf(TableSchema s)
s - -- table schema