com.zphinx.spine.utils
Class PreparedData

java.lang.Object
  extended by com.zphinx.spine.utils.PreparedData

public class PreparedData
extends Object

PreparedData helps create the appropriate prepared statement to use in an sql query using a prepared statement.It contains methods which are useful for creating snippets of preparedStatement sequel

Version:
$1.0

Copyright ©Zphinx Software Solutions

Author:
David Ladapo

Method Summary
 String createSetClause(String[] setParams, String joiner)
          Creates a set clause for an sql prepared statement
 String createWhereClause(String[] whereParams, String[] setParams, String equalType)
          Creates a where clause for an sql prepared statement
 String createWhereClause(String[] whereParams, String setParam, String equalType)
          Creates a where clause for an sql prepared statement
 String createWhereClauseSep(String[] whereParams, String setParam, String equalType, String separator)
          Creates a where clause for an sql prepared statement
 String delete(DataPack dp)
          Creates a delete prepared statement
 String getInsertString(String[] colNames)
          Formats the insert string using the given array of column names
static PreparedData getInstance()
          Gets the only instance of this object
 String getSelectString(String[] colNames, String concat)
          Formats the select string and concatenates the tableName with each column name
 String getUpdateString(String[] colNames)
          Formats the update string using the given column names
protected  String getWhereString(DataPack dataPack, String sql)
          Gets the where statement and conditions
 String insert(DataPack dp)
          Creates an insert prepared statement
 String select(DataPack dp)
          Creates a select prepared statement
 String selectDistinct(DataPack dp)
          Creates a select distinct prepared statement
 String update(DataPack dp)
          Creates an update prepared statement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getWhereString

protected String getWhereString(DataPack dataPack,
                                String sql)
Gets the where statement and conditions

Parameters:
dataPack - The DataPack object which contains the data to render as an sql string
sql - The sql string we are parsing
Returns:
The sql string concatenated with the where statement

delete

public String delete(DataPack dp)
Creates a delete prepared statement

Parameters:
dp - The DataPack object which contains the data to render as an sql string
Returns:
The sql string we are parsing

update

public String update(DataPack dp)
Creates an update prepared statement

Parameters:
dp - The DataPack object which contains the data to render as an sql string
Returns:
The sql prepared statement we are parsing

select

public String select(DataPack dp)
Creates a select prepared statement

Parameters:
dp - The DataPack object which contains the data to render as an sql string
Returns:
The sql prepared statement we are parsing

selectDistinct

public String selectDistinct(DataPack dp)
Creates a select distinct prepared statement

Parameters:
dp - The DataPack object which contains the data to render as an sql string
Returns:
The sql prepared statement we are parsing

insert

public String insert(DataPack dp)
Creates an insert prepared statement

Parameters:
dp - The DataPack object which contains the data to render as an sql string
Returns:
The sql prepared statement we are parsing

createSetClause

public String createSetClause(String[] setParams,
                              String joiner)
Creates a set clause for an sql prepared statement

Parameters:
setParams - The parameters used to create the set clause
joiner - The String to concatenate with
Returns:
The concatenation of set sql statements

getInsertString

public String getInsertString(String[] colNames)
Formats the insert string using the given array of column names

Parameters:
colNames - The array of strings representing the database fields
Returns:
The formatted insert string

getSelectString

public String getSelectString(String[] colNames,
                              String concat)
Formats the select string and concatenates the tableName with each column name

Parameters:
colNames - The array of strings representing the database fields
concat - The name of the table to concatenate to the column name
Returns:
The formatted select string

getUpdateString

public String getUpdateString(String[] colNames)
Formats the update string using the given column names

Parameters:
colNames - The array of strings representing the database fields
Returns:
The formatted update string

createWhereClause

public String createWhereClause(String[] whereParams,
                                String[] setParams,
                                String equalType)
Creates a where clause for an sql prepared statement

Parameters:
whereParams - The logical where clause to set
setParams - The equivalence of the where clause
Returns:
The concatenation of where sql statements

createWhereClause

public String createWhereClause(String[] whereParams,
                                String setParam,
                                String equalType)
Creates a where clause for an sql prepared statement

Parameters:
whereParams - The logical where clause to set
setParam - The equivalence of the where clause
Returns:
The concatenation of where sql statements

createWhereClauseSep

public String createWhereClauseSep(String[] whereParams,
                                   String setParam,
                                   String equalType,
                                   String separator)
Creates a where clause for an sql prepared statement

Parameters:
whereParams - The array of where clauses
setParam - The parameter used to equate the where clause value
equalType - The type of equality sign used to create the where clause
separator - The type of seperator in use
Returns:
A String representing the where clause

getInstance

public static PreparedData getInstance()
Gets the only instance of this object

Returns:
The static instance of this object