ch.sahits.model.db
Class BasicDataBaseTable

java.lang.Object
  extended by ch.sahits.model.db.BasicDataBaseTable
All Implemented Interfaces:
IBasicDataBaseTable, IDBTable, IGeneratedObject

public class BasicDataBaseTable
extends java.lang.Object
implements IDBTable, IBasicDataBaseTable

Implementation of a database table model

Since:
1.2.0
Author:
Andi Hotz

Constructor Summary
BasicDataBaseTable(java.lang.String product)
          Initialize the object with the database product
BasicDataBaseTable(java.lang.String product, java.lang.String _schema)
          Initialize the object with the database product
BasicDataBaseTable(java.lang.String product, java.lang.String _tableName, java.lang.String _schema)
          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)
           
 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.lang.String getDbProductName()
           
 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()
           
 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 setDbProductName(java.lang.String _dbProductName)
           
 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
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicDataBaseTable

public BasicDataBaseTable(java.lang.String product,
                          java.lang.String _tableName,
                          java.lang.String _schema)
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

BasicDataBaseTable

public BasicDataBaseTable(java.lang.String product,
                          java.lang.String _schema)
Initialize the object with the database product

Parameters:
product - Indicates which database product is used (Oracle, MySQL, ...)
_schema - Schema of the table

BasicDataBaseTable

public BasicDataBaseTable(java.lang.String product)
Initialize the object with the database product

Parameters:
product - Indicates which database product is used (Oracle, MySQL, ...)
Method Detail

getDbProductName

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

setDbProductName

public void setDbProductName(java.lang.String _dbProductName)
Parameters:
_dbProductName - the dbProductName to set

getSchema

public java.lang.String getSchema()
Description copied from interface: IDBTable
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()
Description copied from interface: IDBTable
Retrieve the table name

Specified by:
getTableName in interface IBasicDataBaseTable
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 IDBTable
Parameters:
_tableName -

getFields

public java.util.List<DataBaseTableField> getFields()
Description copied from interface: IBasicDataBaseTable
Retrieve a list of the database fields.

Specified by:
getFields in interface IBasicDataBaseTable
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.

Parameters:
field -

getIndexes

public java.util.List<DataBaseTableIndex> getIndexes()
Description copied from interface: IBasicDataBaseTable
Retrieve a list of all table indexes

Specified by:
getIndexes in interface IBasicDataBaseTable
Returns:
DataBaseTableIndex s

setIndexes

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

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.

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)
Description copied from interface: IBasicDataBaseTable
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

findIndex

public DataBaseTableIndex findIndex(java.lang.String indexName)
Description copied from interface: IBasicDataBaseTable
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()
Description copied from interface: IBasicDataBaseTable
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

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

uniqueKeys

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

Specified by:
uniqueKeys 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

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