ch.sahits.model.java.db
Class DataBaseTable

java.lang.Object
  extended by ch.sahits.model.GeneratedClass
      extended by ch.sahits.model.java.GeneratedJavaClass
          extended by ch.sahits.model.java.GeneratedJavaDBClass
              extended by ch.sahits.model.java.db.DataBaseTable
All Implemented Interfaces:
IBasicDataBaseTable, IConnectableDataBaseTable, IDataBaseTable, IDBTable, IGeneratedDBClass, IGeneratedObject, IGeneratorClass, IGeneratorClass2, IGeneratedJavaClass, IGeneratedJavaClass2, IGeneratedJavaDBClass, IGeneratedJavaDBClass2, java.lang.Cloneable

public class DataBaseTable
extends GeneratedJavaDBClass
implements IConnectableDataBaseTable, IBasicDataBaseTable

This bean represents the meta data of a table. Values like field, type, constrains and indexes are stored.

Since:
0.9.0
Author:
Andi Hotz

Constructor Summary
DataBaseTable(java.lang.String product, java.lang.String className)
          Initialize the object with the database product
DataBaseTable(java.lang.String product, java.lang.String packageName, java.lang.String className)
          Initialize the object with the database product
DataBaseTable(java.lang.String product, java.lang.String _schema, java.lang.String packageName, java.lang.String className)
          Initialize the object with the database product
DataBaseTable(java.lang.String product, java.lang.String _tableName, java.lang.String _schema, java.lang.String packageName, java.lang.String className)
          Initialize the object with the database product
 
Method Summary
 void add(DataBaseTableField field)
          Add a database field.
 void add(DataBaseTableIndex ind)
          Add a database index.
 boolean equals(java.lang.Object obj)
          Two database tables are the same if they have the same name, the same fields (irrelevant of their order) and the same indices (irrelevant of their order)
 DataBaseTableField findField(java.lang.String fieldName)
          Find the field with the name fieldName
 DataBaseTableIndex findIndex(java.lang.String indexName)
          Find the index with the name indexName
 DataBaseTableIndex findPrimaryIndex()
          Find the index which's name start with PK_.
 java.util.List<DataBaseTableIndex> forginKeys()
          Retrieve a list of all indexes that represent a forgin key
 java.lang.String getDbName()
           
 java.util.List<DataBaseTableField> getFields()
          Retrieve a list of the database fields.
 java.lang.String getHost()
           
 java.util.List<DataBaseTableIndex> getIndexes()
          Retrieve a list of all table indexes
 java.lang.String getPassword()
           
 java.lang.String getPort()
           
 java.lang.String getSchema()
          Retrieve the schema.
 java.lang.String getTableName()
          Retrieve the table name
 java.lang.String getUserName()
           
 int hashCode()
           
 boolean isPrimaryKey(DataBaseTableField field)
          Check wether the field is part of the primary key
 java.util.List<DataBaseTableIndex> otherKeys()
          Retrieve a list of all indexes that represent an index that is not a primary key nor a forgin key nor a unique index
 void setDbName(java.lang.String _dbName)
           
 void setFieldAt(int index, DataBaseTableField field)
          Set a database field at position index
 void setFieldAt(int index, DataBaseTableIndex ind)
          Set a database index at position index
 void setFields(java.util.List<DataBaseTableField> _fields)
          Set the DataBaseTableField s
 void setHost(java.lang.String _host)
           
 void setIndexes(java.util.List<DataBaseTableIndex> _indexes)
          Set the DataBaseTableIndex s
 void setPassword(java.lang.String _password)
           
 void setPort(java.lang.String _port)
           
 void setSchema(java.lang.String _schema)
          Set the database schema.
 void setTableName(java.lang.String _tableName)
          Set the table name.
 void setUserName(java.lang.String _userName)
           
 java.lang.String toString()
          Convert this into a string representation
 java.util.List<DataBaseTableIndex> uniqueKeys()
          Retrieve a list of all indexes that represent a unique key
 java.util.List<java.lang.Class> usedClasses()
          Return all classes that are used as database fields
 
Methods inherited from class ch.sahits.model.java.GeneratedJavaDBClass
getDbProductName, setDbProductName
 
Methods inherited from class ch.sahits.model.java.GeneratedJavaClass
addSuperClass, getGeneratorClassPath, getInputFilePath, getInterfaces, getJetTemplatePath, getJProject, getPackageName, getReferenceImplementationPath, getSrcPath, getVisibility, interfaces, isAbstract, isAstTemplateUse, isFinal, isGeneratorClassPathInPlugin, isGeneratorUse, isJetFileUse, isJetTemplateInPlugin, isJetTemplateUse, isPackageDefault, isPrivate, isProtected, isPublic, isSympleType, setAbstract, setAstTemplateUse, setFinal, setGeneratorClassPath, setGeneratorClassPathInPlugin, setGeneratorUse, setInputFilePath, setJetFileUse, setJetTemplateInPlugin, setJetTemplatePath, setJetTemplateUse, setJProject, setPackageName, setReferenceImplementationPath, setSrcPath, setVisibility
 
Methods inherited from class ch.sahits.model.GeneratedClass
getClassName, hasSuperClass, setClassName, superclasses
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ch.sahits.model.db.IDBTable
getDbProductName
 
Methods inherited from interface ch.sahits.model.db.IBasicDataBaseTable
getDbProductName
 
Methods inherited from interface ch.sahits.model.java.IGeneratedJavaClass
setAbstract, setAstTemplateUse, setClassName, setFinal, setGeneratorClassPath, setGeneratorClassPathInPlugin, setGeneratorUse, setInputFilePath, setJetFileUse, setJetTemplateInPlugin, setJetTemplatePath, setJetTemplateUse, setJProject, setPackageName, setReferenceImplementationPath, setSrcPath, setVisibility
 
Methods inherited from interface ch.sahits.model.java.IGeneratedJavaClass2
getClassName, getGeneratorClassPath, getInputFilePath, getInterfaces, getJetTemplatePath, getJProject, getPackageName, getReferenceImplementationPath, getSrcPath, getVisibility, interfaces, isAbstract, isAstTemplateUse, isFinal, isGeneratorClassPathInPlugin, isGeneratorUse, isJetFileUse, isJetTemplateInPlugin, isJetTemplateUse, isPackageDefault, isPrivate, isProtected, isPublic, isSympleType
 
Methods inherited from interface ch.sahits.model.IGeneratorClass
addSuperClass
 
Methods inherited from interface ch.sahits.model.IGeneratorClass2
hasSuperClass, superclasses
 

Constructor Detail

DataBaseTable

public DataBaseTable(java.lang.String product,
                     java.lang.String _tableName,
                     java.lang.String _schema,
                     java.lang.String packageName,
                     java.lang.String className)
Initialize the object with the database product

Parameters:
product - Indicates which database product is used (Oracle, MySQL, ...)
_tableName - Name of the table
_schema - Schema of the table, may be null
packageName - name of the package may be null
className - name of the class

DataBaseTable

public DataBaseTable(java.lang.String product,
                     java.lang.String _schema,
                     java.lang.String packageName,
                     java.lang.String className)
Initialize the object with the database product

Parameters:
product - Indicates which database product is used (Oracle, MySQL, ...)
_schema - Schema of the table
packageName - name of the package may be null
className - name of the class

DataBaseTable

public DataBaseTable(java.lang.String product,
                     java.lang.String packageName,
                     java.lang.String className)
Initialize the object with the database product

Parameters:
product - Indicates which database product is used (Oracle, MySQL, ...)
packageName - name of the package
className - name of the class

DataBaseTable

public DataBaseTable(java.lang.String product,
                     java.lang.String className)
Initialize the object with the database product

Parameters:
product - Indicates which database product is used (Oracle, MySQL, ...)
className - name of the class
Method Detail

getSchema

public java.lang.String getSchema()
Retrieve the schema.

Specified by:
getSchema in interface IBasicDataBaseTable
Specified by:
getSchema in interface IDBTable
Returns:
database schema

setSchema

public void setSchema(java.lang.String _schema)
Set the database schema. Stored in upper-case

Specified by:
setSchema in interface IDBTable
Parameters:
_schema -

getTableName

public java.lang.String getTableName()
Retrieve the table name

Specified by:
getTableName in interface IBasicDataBaseTable
Specified by:
getTableName in interface IDataBaseTable
Specified by:
getTableName in interface IDBTable
Returns:
table name

setTableName

public void setTableName(java.lang.String _tableName)
Set the table name. Stored in upper-case

Specified by:
setTableName in interface IDataBaseTable
Specified by:
setTableName in interface IDBTable
Parameters:
_tableName -

getFields

public java.util.List<DataBaseTableField> getFields()
Retrieve a list of the database fields.

Specified by:
getFields in interface IBasicDataBaseTable
Specified by:
getFields in interface IDataBaseTable
Returns:
DataBaseTableField s

setFields

public void setFields(java.util.List<DataBaseTableField> _fields)
Set the DataBaseTableField s

Parameters:
_fields -

setFieldAt

public void setFieldAt(int index,
                       DataBaseTableField field)
Set a database field at position index

Parameters:
index - position
field -

add

public void add(DataBaseTableField field)
Add a database field.

Specified by:
add in interface IDataBaseTable
Parameters:
field -

getIndexes

public java.util.List<DataBaseTableIndex> getIndexes()
Retrieve a list of all table indexes

Specified by:
getIndexes in interface IBasicDataBaseTable
Specified by:
getIndexes in interface IDataBaseTable
Returns:
DataBaseTableIndex s

setIndexes

public void setIndexes(java.util.List<DataBaseTableIndex> _indexes)
Set the DataBaseTableIndex s

Specified by:
setIndexes in interface IDataBaseTable
Parameters:
_indexes -

setFieldAt

public void setFieldAt(int index,
                       DataBaseTableIndex ind)
Set a database index at position index

Parameters:
index - position
ind -

add

public void add(DataBaseTableIndex ind)
Add a database index.

Specified by:
add in interface IDataBaseTable
Parameters:
ind -

toString

public java.lang.String toString()
Convert this into a string representation

Overrides:
toString in class java.lang.Object

findField

public DataBaseTableField findField(java.lang.String fieldName)
Find the field with the name fieldName

Specified by:
findField in interface IBasicDataBaseTable
Parameters:
fieldName - name of the field
Returns:
DataBaseTableField or null if the field is not found

usedClasses

public java.util.List<java.lang.Class> usedClasses()
Return all classes that are used as database fields

Specified by:
usedClasses in interface IDataBaseTable
Returns:
list of all classes

findIndex

public DataBaseTableIndex findIndex(java.lang.String indexName)
Find the index with the name indexName

Specified by:
findIndex in interface IBasicDataBaseTable
Parameters:
indexName - name of the index
Returns:
DataBaseTableIndex or null if the index is not found

findPrimaryIndex

public DataBaseTableIndex findPrimaryIndex()
Find the index which's name start with PK_. If no such index is found the first found unique is returned.

Specified by:
findPrimaryIndex in interface IBasicDataBaseTable
Returns:
Primary index or null if none is found.

getHost

public java.lang.String getHost()
Specified by:
getHost in interface IBasicDataBaseTable
Specified by:
getHost in interface IDBTable
Returns:
the host

setHost

public void setHost(java.lang.String _host)
Specified by:
setHost in interface IDBTable
Parameters:
_host - the host to set

getPort

public java.lang.String getPort()
Specified by:
getPort in interface IBasicDataBaseTable
Specified by:
getPort in interface IDBTable
Returns:
the port

setPort

public void setPort(java.lang.String _port)
Specified by:
setPort in interface IDBTable
Parameters:
_port - the port to set

getUserName

public java.lang.String getUserName()
Specified by:
getUserName in interface IBasicDataBaseTable
Specified by:
getUserName in interface IDBTable
Returns:
the userName

setUserName

public void setUserName(java.lang.String _userName)
Specified by:
setUserName in interface IDBTable
Parameters:
_userName - the userName to set

getPassword

public java.lang.String getPassword()
Specified by:
getPassword in interface IBasicDataBaseTable
Specified by:
getPassword in interface IDBTable
Returns:
the password

setPassword

public void setPassword(java.lang.String _password)
Specified by:
setPassword in interface IDBTable
Parameters:
_password - the password to set

getDbName

public java.lang.String getDbName()
Specified by:
getDbName in interface IBasicDataBaseTable
Specified by:
getDbName in interface IDBTable
Returns:
the dbName

setDbName

public void setDbName(java.lang.String _dbName)
Specified by:
setDbName in interface IDBTable
Parameters:
_dbName - the dbName to set

hashCode

public int hashCode()
Overrides:
hashCode in class GeneratedJavaClass
See Also:
Object.hashCode()

equals

public boolean equals(java.lang.Object obj)
Two database tables are the same if they have the same name, the same fields (irrelevant of their order) and the same indices (irrelevant of their order)

Overrides:
equals in class GeneratedJavaClass
See Also:
Object.equals(java.lang.Object)

uniqueKeys

public java.util.List<DataBaseTableIndex> uniqueKeys()
Retrieve a list of all indexes that represent a unique key

Specified by:
uniqueKeys in interface IBasicDataBaseTable
Specified by:
uniqueKeys in interface IDataBaseTable
Returns:
List of indexes
Since:
1.2.0

isPrimaryKey

public boolean isPrimaryKey(DataBaseTableField field)
Check wether the field is part of the primary key

Parameters:
field - to be checked
Returns:
true if the field is part of the primary key

forginKeys

public java.util.List<DataBaseTableIndex> forginKeys()
Description copied from interface: IBasicDataBaseTable
Retrieve a list of all indexes that represent a forgin key

Specified by:
forginKeys in interface IBasicDataBaseTable
Returns:
List of indexes

otherKeys

public java.util.List<DataBaseTableIndex> otherKeys()
Description copied from interface: IBasicDataBaseTable
Retrieve a list of all indexes that represent an index that is not a primary key nor a forgin key nor a unique index

Specified by:
otherKeys in interface IBasicDataBaseTable
Returns:
List of indexes