dk.eobjects.metamodel.schema
Class Table

Package class diagram package Table
java.lang.Object
  extended by dk.eobjects.metamodel.schema.Table
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Table>
Direct Known Subclasses:
JdbcTable

public class Table
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable<Table>

Represents the metadata about a table. Tables reside within a schema and contains columns and relationships to other tables.

See Also:
Schema, Column, Relationship, Serialized Form

Field Summary
protected  java.util.List<Column> _columns
           
protected  java.lang.String _name
           
protected  java.lang.String _quoteString
           
protected  java.util.List<Relationship> _relationships
           
protected  java.lang.String _remarks
           
protected  Schema _schema
           
protected  TableType _type
           
 
Constructor Summary
Table()
           
Table(java.lang.String name)
           
Table(java.lang.String name, TableType type)
           
Table(java.lang.String name, TableType type, Schema schema)
           
Table(java.lang.String name, TableType type, Schema schema, Column... columns)
           
 
Method Summary
 Table addColumn(Column column)
           
protected  Table addRelationship(Relationship relation)
          Protected method for adding a relationship to this table.
 int compareTo(Table that)
           
 boolean equals(java.lang.Object obj)
           
protected  void fireSchemaChanged()
          Tells the table object that the schema it belongs to have changed.
 Column[] getBooleanColumns()
           
 Column getColumnByName(java.lang.String columnName)
          Convenience method for retrieving a column by it's name
 int getColumnCount()
           
 java.lang.String[] getColumnNames()
           
 Column[] getColumns()
           
protected  java.util.List<Column> getColumnsInternal()
          Internal getter for the columns of the table.
 Column[] getColumnsOfType(ColumnType columnType)
           
 Relationship[] getForeignKeyRelationships()
           
 Column[] getForeignKeys()
           
 Column[] getIndexedColumns()
           
 Column[] getLiteralColumns()
           
 java.lang.String getName()
           
 Column[] getNumberColumns()
           
 Relationship[] getPrimaryKeyRelationships()
           
 Column[] getPrimaryKeys()
           
 java.lang.String getQualifiedLabel()
          Gets a label with a simple dot-separated qualified name such as "MY_SCHEMA.MY_TABLE".
 java.lang.String getQuote()
           
 java.lang.String getQuotedName()
           
 int getRelationshipCount()
           
 Relationship[] getRelationships()
           
 Relationship[] getRelationships(Table otherTable)
           
protected  java.util.List<Relationship> getRelationshipsInternal()
          Internal getter for the relationships of the table.
 java.lang.String getRemarks()
           
 Schema getSchema()
           
 Column[] getTimeBasedColumns()
           
 TableType getType()
           
 int hashCode()
           
 Table removeColumn(Column column)
           
protected  Table removeRelationship(Relationship relation)
          Protected method for removing a relationship from this table.
 Table setColumns(java.util.Collection<Column> columns)
           
 Table setColumns(Column... columns)
           
 Table setName(java.lang.String name)
           
 Table setQuote(java.lang.String quoteString)
           
 void setRemarks(java.lang.String remarks)
           
 Table setSchema(Schema schema)
           
 Table setType(TableType type)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

_name

protected java.lang.String _name

_type

protected TableType _type

_remarks

protected java.lang.String _remarks

_schema

protected Schema _schema

_columns

protected java.util.List<Column> _columns

_relationships

protected java.util.List<Relationship> _relationships

_quoteString

protected java.lang.String _quoteString
Constructor Detail

Table

public Table()

Table

public Table(java.lang.String name)

Table

public Table(java.lang.String name,
             TableType type)

Table

public Table(java.lang.String name,
             TableType type,
             Schema schema)

Table

public Table(java.lang.String name,
             TableType type,
             Schema schema,
             Column... columns)
Method Detail

getName

public java.lang.String getName()
Returns:
the name of the table

setName

public Table setName(java.lang.String name)

getColumnsInternal

protected java.util.List<Column> getColumnsInternal()
Internal getter for the columns of the table. Overwrite this method to implement column lookup, column lazy-loading or similar.


getRelationshipsInternal

protected java.util.List<Relationship> getRelationshipsInternal()
Internal getter for the relationships of the table. Overwrite this method to implement relationship lookup, relationship lazy-loading or similar.


getColumnCount

public int getColumnCount()
Returns:
the number of columns in this table

getColumns

public Column[] getColumns()
Returns:
the columns of the table

setColumns

public Table setColumns(Column... columns)

setColumns

public Table setColumns(java.util.Collection<Column> columns)

addColumn

public Table addColumn(Column column)

removeColumn

public Table removeColumn(Column column)

getColumnByName

public Column getColumnByName(java.lang.String columnName)
Convenience method for retrieving a column by it's name

Parameters:
columnName - the name of the column to retrieve
Returns:
the column with the given name. Returns null if no such column is found.

getSchema

public Schema getSchema()
Returns:
the schema that the table belong to

setSchema

public Table setSchema(Schema schema)

fireSchemaChanged

protected void fireSchemaChanged()
Tells the table object that the schema it belongs to have changed. This is typically done if the schema is being renamed or similar.


getType

public TableType getType()
Returns:
the type of table

setType

public Table setType(TableType type)

getRelationships

public Relationship[] getRelationships()
Returns:
all relations for this table. To add relations use TableRelation.createRelation();

getRelationships

public Relationship[] getRelationships(Table otherTable)
Parameters:
otherTable -
Returns:
this tables relationsips to another table

addRelationship

protected Table addRelationship(Relationship relation)
Protected method for adding a relationship to this table. Should not be used. Use Relationship.createRelationship(Column[], Column[]) instead.


removeRelationship

protected Table removeRelationship(Relationship relation)
Protected method for removing a relationship from this table. Should not be used. Use Relationship.remove() instead.


getRelationshipCount

public int getRelationshipCount()

getRemarks

public java.lang.String getRemarks()

setRemarks

public void setRemarks(java.lang.String remarks)

getQuote

public java.lang.String getQuote()

setQuote

public Table setQuote(java.lang.String quoteString)

getQuotedName

public java.lang.String getQuotedName()

getQualifiedLabel

public java.lang.String getQualifiedLabel()
Gets a label with a simple dot-separated qualified name such as "MY_SCHEMA.MY_TABLE". The qualified label can be used as a unique identifier for the table but is not necessarily directly transferable to SQL syntax.

Returns:
a qualified label

getNumberColumns

public Column[] getNumberColumns()

getLiteralColumns

public Column[] getLiteralColumns()

getTimeBasedColumns

public Column[] getTimeBasedColumns()

getBooleanColumns

public Column[] getBooleanColumns()

getIndexedColumns

public Column[] getIndexedColumns()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(Table that)
Specified by:
compareTo in interface java.lang.Comparable<Table>

getForeignKeyRelationships

public Relationship[] getForeignKeyRelationships()
Returns:
the relationships where this table is the foreign table

getPrimaryKeyRelationships

public Relationship[] getPrimaryKeyRelationships()
Returns:
the relationships where this table is the primary table

getForeignKeys

public Column[] getForeignKeys()

getPrimaryKeys

public Column[] getPrimaryKeys()

getColumnNames

public java.lang.String[] getColumnNames()

getColumnsOfType

public Column[] getColumnsOfType(ColumnType columnType)


Copyright © 2007-2010. All Rights Reserved.