pt.moredata.dao.core
Class AbstractSQLStatementBuilder

java.lang.Object
  extended bypt.moredata.dao.core.AbstractSQLStatementBuilder
All Implemented Interfaces:
SQLStatementBuilder
Direct Known Subclasses:
SQLDeleteBuilder, SQLInsertBuilder, SQLSelectBuilder, SQLUpdateBuilder

public abstract class AbstractSQLStatementBuilder
extends java.lang.Object
implements SQLStatementBuilder

AbstractSQLStatementBuilder.java Company MoreData

Version:
$Revision: 1.10 $
Author:
pcarmo

Field Summary
protected  DAOFieldsInfo _fieldsInfo
          DAOFieldsInfo object with information about DAO columns and tables.
protected  SQLInformation _info
          Aditional information to build the SQL command.
protected  RecordSet _recordSet
          DAO RecordSet.
 
Constructor Summary
AbstractSQLStatementBuilder(DAOFieldsInfo fieldsInfo, RecordSet recordSet)
          Creates a new instance of AbstractSQLStatementBuilder
 
Method Summary
protected abstract  java.lang.String getSQLStatement()
          Builds a SQL command for interacting with a table of a relational database repository.
 java.lang.String getSQLStatement(SQLInformation info)
          Builds a SQL command for interacting with a table of a relational database repository.
protected static java.lang.Object getStringObjectWithSpaceAtEnd(java.lang.Object obj, MetaField mf)
          Add spaces to the Object if the Obect is a String and the column type is CHAR(n).
 void setDAOFieldsInfo(DAOFieldsInfo fieldsInfo)
          Set the DAOFieldsInfo object with information about the columns of the RecordSet.
 void setRecordSet(RecordSet recordSet)
          Set the RecordSet used to store the information read from the repository.
protected  void setRecordValue(java.sql.PreparedStatement statement, int statementIndex, int rowNumber, MetaField field)
          Afecta os dados ao statement enviado como parametro na posição pretendida verificando se estes estão ou não nulos Ainda é dependente do tipo de dados pois o setNull obriga a tipo de dados
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface pt.moredata.dao.SQLStatementBuilder
loadData, setStatementParameters
 

Field Detail

_info

protected SQLInformation _info
Aditional information to build the SQL command.


_fieldsInfo

protected DAOFieldsInfo _fieldsInfo
DAOFieldsInfo object with information about DAO columns and tables.


_recordSet

protected RecordSet _recordSet
DAO RecordSet.

Constructor Detail

AbstractSQLStatementBuilder

public AbstractSQLStatementBuilder(DAOFieldsInfo fieldsInfo,
                                   RecordSet recordSet)
Creates a new instance of AbstractSQLStatementBuilder

Parameters:
fieldsInfo - The DAO fields information object.
recordSet - The DAO RecordSet object witch contains the DAO data.
Method Detail

getSQLStatement

protected abstract java.lang.String getSQLStatement()
Builds a SQL command for interacting with a table of a relational database repository.

Returns:
A string with the SQL command for interacting with a table of a relational database repository.

setRecordValue

protected void setRecordValue(java.sql.PreparedStatement statement,
                              int statementIndex,
                              int rowNumber,
                              MetaField field)
                       throws java.sql.SQLException
Afecta os dados ao statement enviado como parametro na posição pretendida verificando se estes estão ou não nulos

Ainda é dependente do tipo de dados pois o setNull obriga a tipo de dados

Parameters:
rowNumber - numero da linha.
field - MetaField que representa a linha.
statementIndex - Index da coluna para a qual se vai afectar o valor.
statement - Prepared Statement
Throws:
java.sql.SQLException - Se ocorrer erro na passagem de dados ao motor.

getStringObjectWithSpaceAtEnd

protected static java.lang.Object getStringObjectWithSpaceAtEnd(java.lang.Object obj,
                                                                MetaField mf)
Add spaces to the Object if the Obect is a String and the column type is CHAR(n). The number of space add to the String object is such that the final String object length is n.

Parameters:
obj - The String object.
mf - The column meta field descriptor.
Returns:
The sample object if it isn't a String or the original String with spaces at the end.

setDAOFieldsInfo

public void setDAOFieldsInfo(DAOFieldsInfo fieldsInfo)
Description copied from interface: SQLStatementBuilder
Set the DAOFieldsInfo object with information about the columns of the RecordSet.

Specified by:
setDAOFieldsInfo in interface SQLStatementBuilder
Parameters:
fieldsInfo - The DAOFieldInfo object.

setRecordSet

public void setRecordSet(RecordSet recordSet)
Description copied from interface: SQLStatementBuilder
Set the RecordSet used to store the information read from the repository.

Specified by:
setRecordSet in interface SQLStatementBuilder
Parameters:
recordSet - The RecorSet object to store the readed information.

getSQLStatement

public java.lang.String getSQLStatement(SQLInformation info)
Builds a SQL command for interacting with a table of a relational database repository.

Specified by:
getSQLStatement in interface SQLStatementBuilder
Parameters:
info - Adicional information to help building the sql statement.