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
|
TableSchema(TableSchema ts)
create a copy (not a deep copy) of a given schema
|
Modifier and Type | Method and Description |
---|---|
TableSchema |
add(Column... columns) |
TableSchema |
add(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 |
add(java.lang.String... columns)
adds a sequence of columns
|
TableSchema |
add(java.lang.String k)
adds a column whose name/type is encoded by k
|
TableSchema |
addFirst(Column... columns)
place an array of columns before existing columns of 'this' schema
|
TableSchema |
addFirst(Column c)
add column c as the first of 'this' schema
|
TableSchema |
addFirst(java.lang.String... columns)
add list of columns to the head of a schema
|
TableSchema |
addFirst(java.lang.String k)
adds a column to the head of the list of columns
|
void |
AssertNotAbstract() |
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
|
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.lang.String[] |
getColumnNames()
appends an array of column names of 'this' table schema to given array
|
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
|
java.util.List<Column> |
getUnInheritedColumns() |
boolean |
hasColumn(java.lang.String columnName)
does schema have a column with columnName?
|
void |
hasColumnEH(java.lang.String columnName)
does schema have a column with columnName?
|
boolean |
isAbstract() |
boolean |
isDetached() |
boolean |
isSuperTableOf(TableSchema s)
is 'this' schema a supertable (ancestor) of table schema s?
|
void |
makeAbstract()
setter and getter of abstract property
|
void |
makeConcrete() |
void |
print()
print to System.out
|
void |
print(java.io.PrintStream out)
print 'this' TableSchema to PrintStream out
|
static TableSchema |
read(java.io.File schemafile)
reads prolog schema from File schemafile; errors are reported to out
read only .schema and database files
|
static TableSchema |
read(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 |
read(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 TableSchema(TableSchema ts)
ts
- -- table schema to copypublic java.lang.String getName()
public void makeAbstract()
public boolean isAbstract()
public void AssertNotAbstract()
public void makeConcrete()
public Column getColumn(int i)
i
- column index (first column is index = 0public java.lang.String getIDName()
public java.util.List<Column> getColumns()
public java.util.List<Column> getUnInheritedColumns()
public java.lang.String[] getColumnNames()
public boolean hasColumn(java.lang.String columnName)
columnName
- -- column name to verify existencepublic 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 copyFrompublic static TableSchema read(java.lang.String schemafileName)
schemafileName
- name of the file that contains a single Table
declarationpublic static TableSchema read(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 read(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 add(Column c)
c
- is column to addpublic TableSchema addFirst(Column c)
c
- column to addpublic TableSchema add(java.lang.String k)
k
- -- either an identifier or 'identifier'public TableSchema addFirst(java.lang.String k)
k
- -- either an identifier or 'identifier'public TableSchema add(java.lang.String... columns)
columns
- -- sequence of column-encoded namespublic TableSchema add(Column... columns)
public TableSchema addFirst(java.lang.String... columns)
columns
- -- encoded names of columns to addpublic TableSchema addFirst(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 printpublic void print()
public TableSchema getSuperTableOf()
public boolean isSuperTableOf(TableSchema s)
s
- -- table schema