|
Dresden OCL Toolkit | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttudresden.ocl.codegen.decl.Table
This class represents metadata about tables of relational databases.
A table consists of:
- an arbitrary number of columns;
- a primary key consisting of zero ore more columns;
- foreign key references consisting of zero or more columns;
The columns of the table can be associated to an attribute name that can
be different from the real column name. The columns of the table can
have a type. Since the metadata is not dependend of a specific database
system, no special types are prescribed. It is suggested to follow the
java basic data types like int, long, boolean, real and so on and map
them to the specific database system types if necessary. The foreign
keys are ordinary columns that are associated to additional information.
These information are:
- the name of a foreign table;(deprecated)
modified for reference to foreign table object
- the name of a column in the foreign table.
- possibly other columns that are part of the same (multiple) foreign key
Nested Class Summary | |
private class |
Table.Column
|
Field Summary | |
private List |
columns
|
private static String |
EX_COL_NE
|
private static String |
EX_COL_NULL
|
private static String |
EX_DUPL_COL
|
private static String |
EX_FCOL_NE
|
private static String |
EX_FK_SNOTS
|
private static String |
EX_TMAC
|
private String |
name
|
Constructor Summary | |
Table(String name)
Creates a new empty table. |
Method Summary | |
void |
addColumn(String colName)
Adds a new column to the table. |
void |
addColumn(String attName,
String colName,
boolean pk)
Adds a new column to the table. |
void |
addColumn(String attName,
String type,
String colName)
Adds a new column to the table. |
void |
addColumn(String attName,
String type,
String colName,
boolean pk)
Adds a new column to the table. |
protected void |
addReferringTable(String referredColumn,
Table referringTable,
String referringColumn)
used to set the reverse table reference for foreign key references |
Set |
attributes()
|
String[] |
getAllForeignKeyColumns(String colName)
|
String |
getAttributeColumn(String attName)
|
String[] |
getAttributeColumns(String attName)
|
private Table.Column |
getColumn(String colName)
|
String |
getColumnAttribute(String colName)
|
String[] |
getColumns()
|
String |
getColumnType(String colName)
|
String |
getForeignColumn(String colName)
|
String[] |
getForeignKeyColumns()
|
String |
getForeignKeyRepresentation(String colName)
|
String |
getForeignTable(String colName)
|
String[] |
getKeyColumns()
Deprecated. Use methode getPrimaryKeyColumns instead ! |
String[] |
getPrimaryKeyColumns()
|
String |
getPrimaryKeyRepresentation()
|
Table |
getReferredTable(String colName)
|
String |
getTableName()
|
boolean |
isColumn(String colName)
|
boolean |
isForeignKeyColumn(String colName)
|
boolean |
isKeyColumn(String colName)
Deprecated. Use methode isPrimaryKeyColumn instead ! |
boolean |
isOptional(String colName)
|
boolean |
isPrimaryKeyColumn(String colName)
|
void |
removeColumn(String colName)
|
void |
removePrimaryKey()
|
void |
setColumnType(String colName,
String colType)
|
void |
setForeignKey(String[] colNames,
Table fkTable,
String[] fkColumns)
Marks the specified columns as multi column foreign key reference. |
void |
setForeignKey(String colName,
String fkTable,
String fkColumn)
Deprecated. use setForeignKey(String colName, Table fkTable, String fkColumn) instead |
void |
setForeignKey(String colName,
Table fkTable,
String fkColumn)
Sets the specified column to foreign key state. |
void |
setName(String name)
sets the Table's name |
void |
setOptional(String colName)
marks a column as optional column (may contain null values) |
void |
setPrimaryKey(String colName)
Sets the specified column to primary key column state. |
String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private static String EX_DUPL_COL
private static String EX_COL_NULL
private static String EX_COL_NE
private static String EX_FCOL_NE
private static String EX_FK_SNOTS
private static String EX_TMAC
private List columns
private String name
Constructor Detail |
public Table(String name)
name
- the name of the tableMethod Detail |
public void addColumn(String colName) throws NullPointerException, IllegalArgumentException
colName
- the name of the column
NullPointerException
- if colName is null
IllegalArgumentException
- if colName still existspublic void addColumn(String attName, String type, String colName) throws NullPointerException, IllegalArgumentException
attName
- the name of the attribute associated to the columntype
- the type name of the columncolName
- the name of the column
NullPointerException
- if colName is null
IllegalArgumentException
- if colName still existspublic void addColumn(String attName, String colName, boolean pk) throws NullPointerException, IllegalArgumentException
attName
- the name of the attribute associated to the columncolName
- the name of the columnpk
- a flag that should be true if the column is a primary key column, false otherwise
NullPointerException
- if colName is null
IllegalArgumentException
- if colName still existspublic void addColumn(String attName, String type, String colName, boolean pk) throws NullPointerException, IllegalArgumentException
attName
- the name of the attribute associated to the columntype
- the type name of the columncolName
- the name of the columnpk
- a flag that should be true if the column is a primary key column, false otherwise
NullPointerException
- if colName is null
IllegalArgumentException
- if colName still existspublic void setPrimaryKey(String colName) throws NullPointerException, IllegalArgumentException
colName
- the column name
NullPointerException
- if colName is null
IllegalArgumentException
- if colName does not existspublic void setForeignKey(String colName, String fkTable, String fkColumn) throws NullPointerException, IllegalArgumentException
colName
- the column namefkTable
- the name of the foreign tablefkColumn
- the name of the foreign column
NullPointerException
- if one of colName, fkTable or fkColumn is null
IllegalArgumentException
- if colName does not existspublic void setForeignKey(String colName, Table fkTable, String fkColumn) throws NullPointerException, IllegalArgumentException
colName
- the column namefkTable
- the foreign tablefkColumn
- the name of the foreign column
NullPointerException
- if one of colName, fkTable or fkColumn is null
IllegalArgumentException
- if colName does not existspublic void setForeignKey(String[] colNames, Table fkTable, String[] fkColumns) throws NullPointerException, IllegalArgumentException
colNames
- the column names that are part of the foreign keyfkTable
- the foreign tablefkColumns
- the names of the corresponding foreign columns
NullPointerException
- if one of colName, fkTable or fkColumn is null
IllegalArgumentException
- if colName does not exists or columns do not match foreign columnsprotected void addReferringTable(String referredColumn, Table referringTable, String referringColumn)
public String[] getColumns()
public String getAttributeColumn(String attName) throws NullPointerException, IllegalStateException
attName
- the name of an attribute
NullPointerException
- if attName is null
IllegalStateException
- if the specified attribute is mapped to more than one columnpublic String[] getAttributeColumns(String attName) throws NullPointerException
attName
- the name of an attribute
NullPointerException
- if attName is nullpublic String getColumnAttribute(String colName) throws NullPointerException, IllegalArgumentException
colName
- the name of a column
NullPointerException
- if colName is null
IllegalArgumentException
- if colName does not existspublic String[] getKeyColumns()
public String[] getPrimaryKeyColumns()
public String[] getForeignKeyColumns()
public String getColumnType(String colName) throws NullPointerException, IllegalArgumentException
colName
- the name of a column
NullPointerException
- if colName is null
IllegalArgumentException
- if colName does not existspublic void setColumnType(String colName, String colType) throws NullPointerException, IllegalArgumentException
NullPointerException
IllegalArgumentException
public String getForeignTable(String colName) throws NullPointerException, IllegalArgumentException
colName
- the name of a column
NullPointerException
- if colName is null
IllegalArgumentException
- if colName does not existspublic Table getReferredTable(String colName) throws NullPointerException, IllegalArgumentException
colName
- the name of a column
NullPointerException
- if colName is null
IllegalArgumentException
- if colName does not existspublic String getForeignColumn(String colName) throws NullPointerException, IllegalArgumentException
colName
- the name of a column
NullPointerException
- if colName is null
IllegalArgumentException
- if colName does not existspublic String[] getAllForeignKeyColumns(String colName) throws NullPointerException, IllegalArgumentException
colName
- the name of a column
NullPointerException
- if colName is null
IllegalArgumentException
- if colName does not existspublic String getForeignKeyRepresentation(String colName) throws NullPointerException, IllegalArgumentException
NullPointerException
IllegalArgumentException
public String getPrimaryKeyRepresentation()
public String getTableName()
public boolean isKeyColumn(String colName) throws NullPointerException
colName
- the name of a column
NullPointerException
- if colName is nullpublic boolean isPrimaryKeyColumn(String colName) throws NullPointerException
colName
- the name of a column
NullPointerException
- if colName is nullpublic boolean isForeignKeyColumn(String colName) throws NullPointerException
colName
- the name of a column
NullPointerException
- if colName is nullpublic boolean isColumn(String colName) throws NullPointerException
colName
- the name of a column
NullPointerException
- if colName is nullpublic Set attributes()
public void setName(String name)
public void setOptional(String colName) throws IllegalArgumentException
IlleglArgumentException
- if column does not exist
IllegalArgumentException
public boolean isOptional(String colName) throws IllegalArgumentException
IlleglArgumentException
- if column does not exist
IllegalArgumentException
public void removeColumn(String colName) throws IllegalArgumentException
colName
- the column to remove
IlleglArgumentException
- if column is Part of the primary key or of a foreign key
IllegalArgumentException
public void removePrimaryKey() throws IllegalArgumentException
IlleglArgumentException
- if primary key is referred to
IllegalArgumentException
public String toString()
private Table.Column getColumn(String colName)
colName
- the name of a column
|
Dresden OCL Toolkit | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |