anderix.datajets
Class SqlBuilder

java.lang.Object
  extended by anderix.datajets.SqlBuilder

public class SqlBuilder
extends java.lang.Object

Facilitates creation of SQL statements in an object-oriented manner. The basic use of a SqlBuilder object follows this pattern:

  1. Instantiate SqlBuilder object
  2. Define table to connect to
  3. Define fields in that table
  4. Define identity field (if applicable)
  5. Set field values (if applicable)
  6. Return completed SQL statement
For example, this code creates a SELECT statement:
//Example: creating a SELECT statement
SqlBuilder sql = new SqlBuilder;
String table = "my_table";
sql.setTable(table);
String[] fields = new String[]{"field1", "field2"};
sql.setFieldList(fields);
System.out.println(sql.selectStatement());
SqlBuilder contains methods for adding WHERE clauses to SELECT, INSERT, UPDATE, and DELETE statements. There are also methods for adding JOIN, GROUP BY, HAVING, and ORDER BY clauses to SELECT statements. Calling these methods for INSERT, UPDATE or DELETE statements will have no effect.

Some statments require that the identity field be specified. This can be done in the setFieldList method or in an appropriate constructor. The methods that require an identity field are:

When creating an INSERT or UPDATE statment, you may populate parameter values by calling setFieldValue or setFieldValueToNull. If you do not set field values, the statement will be returned with ? as a placeholder value.

If SqlBuilder does not have enough information to create the requested SQL statement, it will return an empty string ("");


Constructor Summary
SqlBuilder()
          Constructor that does not establish table, fields or identity field.
SqlBuilder(java.lang.String table)
          Constructor that establishes table.
SqlBuilder(java.lang.String table, java.lang.String[] fields)
          Constructor that establishes table and fields.
SqlBuilder(java.lang.String table, java.lang.String[] fields, int idFieldIndex)
          Constructor that establishes table, fields, and identity field.
SqlBuilder(java.lang.String table, java.lang.String[] fields, java.lang.String idField)
          Constructor that establishes table, fields, and identity field.
SqlBuilder(java.lang.String table, java.lang.String[] fields, java.lang.String[] fieldProperties, int idFieldIndex)
          Constructor that establishes table, fields, field properties and identity field.
 
Method Summary
 void addField(java.lang.String fieldName)
          Adds a single field to the field list.
 void andHaving(int fieldIndex, Comparison operator, boolean value)
          Adds a HAVING clause to a SELECT statement with AND.
 void andHaving(int fieldIndex, Comparison operator, byte value)
          Adds a HAVING clause to a SELECT statement with AND.
 void andHaving(int fieldIndex, Comparison operator, java.util.Date value)
          Adds a HAVING clause to a SELECT statement with AND.
 void andHaving(int fieldIndex, Comparison operator, double value)
          Adds a HAVING clause to a SELECT statement with AND.
 void andHaving(int fieldIndex, Comparison operator, float value)
          Adds a HAVING clause to a SELECT statement with AND.
 void andHaving(int fieldIndex, Comparison operator, int value)
          Adds a HAVING clause to a SELECT statement with AND.
 void andHaving(int fieldIndex, Comparison operator, short value)
          Adds a HAVING clause to a SELECT statement with AND.
 void andHaving(int fieldIndex, Comparison operator, java.lang.String value)
          Adds a HAVING clause to a SELECT statement with AND.
 void andHaving(java.lang.String havingStatement)
          Adds a HAVING clause to a SELECT statement with AND.
 void andHaving(java.lang.String fieldName, Comparison operator, boolean value)
          Adds a HAVING clause to a SELECT statement with AND.
 void andHaving(java.lang.String fieldName, Comparison operator, byte value)
          Adds a HAVING clause to a SELECT statement with AND.
 void andHaving(java.lang.String fieldName, Comparison operator, java.util.Date value)
          Adds a HAVING clause to a SELECT statement with AND.
 void andHaving(java.lang.String fieldName, Comparison operator, double value)
          Adds a HAVING clause to a SELECT statement with AND.
 void andHaving(java.lang.String fieldName, Comparison operator, float value)
          Adds a HAVING clause to a SELECT statement with AND.
 void andHaving(java.lang.String fieldName, Comparison operator, int value)
          Adds a HAVING clause to a SELECT statement with AND.
 void andHaving(java.lang.String fieldName, Comparison operator, short value)
          Adds a HAVING clause to a SELECT statement with AND.
 void andHaving(java.lang.String fieldName, Comparison operator, java.lang.String value)
          Adds a HAVING clause to a SELECT statement with AND.
 void andWhere(int fieldIndex, Comparison operator, boolean value)
          Adds a WHERE clause to an SQL statement with AND.
 void andWhere(int fieldIndex, Comparison operator, byte value)
          Adds a WHERE clause to an SQL statement with AND.
 void andWhere(int fieldIndex, Comparison operator, java.util.Date value)
          Adds a WHERE clause to an SQL statement with AND.
 void andWhere(int fieldIndex, Comparison operator, double value)
          Adds a WHERE clause to an SQL statement with AND.
 void andWhere(int fieldIndex, Comparison operator, float value)
          Adds a WHERE clause to an SQL statement with AND.
 void andWhere(int fieldIndex, Comparison operator, int value)
          Adds a WHERE clause to an SQL statement with AND.
 void andWhere(int fieldIndex, Comparison operator, short value)
          Adds a WHERE clause to an SQL statement with AND.
 void andWhere(int fieldIndex, Comparison operator, java.lang.String value)
          Adds a WHERE clause to an SQL statement with AND.
 void andWhere(java.lang.String whereStatement)
          Adds a WHERE clause to an SQL statement with AND.
 void andWhere(java.lang.String fieldName, Comparison operator, boolean value)
          Adds a WHERE clause to an SQL statement with AND.
 void andWhere(java.lang.String fieldName, Comparison operator, byte value)
          Adds a WHERE clause to an SQL statement with AND.
 void andWhere(java.lang.String fieldName, Comparison operator, java.util.Date value)
          Adds a WHERE clause to an SQL statement with AND.
 void andWhere(java.lang.String fieldName, Comparison operator, double value)
          Adds a WHERE clause to an SQL statement with AND.
 void andWhere(java.lang.String fieldName, Comparison operator, float value)
          Adds a WHERE clause to an SQL statement with AND.
 void andWhere(java.lang.String fieldName, Comparison operator, int value)
          Adds a WHERE clause to an SQL statement with AND.
 void andWhere(java.lang.String fieldName, Comparison operator, short value)
          Adds a WHERE clause to an SQL statement with AND.
 void andWhere(java.lang.String fieldName, Comparison operator, java.lang.String value)
          Adds a WHERE clause to an SQL statement with AND.
 java.lang.String createTableStatement()
          Creates a CREATE TABLE statement based on supplied values.
 java.lang.String deleteByIdStatement(int idToDelete)
          Creates an DELETE statement based on supplied values.
 java.lang.String deleteStatement()
          Creates an DELETE statement based on supplied values.
static java.lang.String encode(java.lang.String toEncode)
          Modifies a string so it will be processed as a complete string within SQL.
 java.lang.String[] getFieldList()
          Returns array of strings representing field names already established.
 java.lang.String getTable()
          Returns string representing table name already established.
 void groupBy(int groupByFieldIndex)
          Adds a GROUP BY clause to a SELECT statement.
 void groupBy(java.lang.String groupByField)
          Adds a GROUP BY clause to a SELECT statement.
 java.lang.String insertStatement()
          Creates a INSERT statement based on supplied values.
 void join(JoinType joinType, java.lang.String tableToJoin, java.lang.String onStatement)
          Adds a JOIN clause to an SQL statement.
 void join(JoinType joinType, java.lang.String tableToJoin, java.lang.String fieldInFirstTable, Comparison operator, java.lang.String fieldInTableToJoin)
          Adds a JOIN clause to an SQL statement.
 void join(java.lang.String tableToJoin, java.lang.String onStatement)
          Adds an INNER JOIN clause to an SQL statement.
 void join(java.lang.String tableToJoin, java.lang.String fieldInFirstTable, Comparison operator, java.lang.String fieldInTableToJoin)
          Adds an INNER JOIN clause to an SQL statement.
 void join(java.lang.String tableToJoin, java.lang.String fieldInFirstTable, java.lang.String fieldInTableToJoin)
          Adds an INNER JOIN clause to an SQL statement.
 void orderBy(int orderByFieldIndex, OrderDirection direction)
          Adds an ORDER BY clause to a SELECT statement with direction as the direction.
 void orderBy(java.lang.String orderByField, OrderDirection direction)
          Adds a ORDER BY clause to a SELECT statement with direction as the direction.
 void orderByAscending(int orderByFieldIndex)
          Adds an ORDER BY clause to a SELECT statement with ASC as the direction.
 void orderByAscending(java.lang.String orderByField)
          Adds a ORDER BY clause to a SELECT statement with ASC as the direction.
 void orderByDescending(int orderByFieldIndex)
          Adds an ORDER BY clause to a SELECT statement with DESC as the direction.
 void orderByDescending(java.lang.String orderByField)
          Adds a ORDER BY clause to a SELECT statement with DESC as the direction.
 void orHaving(int fieldIndex, Comparison operator, boolean value)
          Adds a HAVING clause to a SELECT statement with OR.
 void orHaving(int fieldIndex, Comparison operator, byte value)
          Adds a HAVING clause to a SELECT statement with OR.
 void orHaving(int fieldIndex, Comparison operator, java.util.Date value)
          Adds a HAVING clause to a SELECT statement with OR.
 void orHaving(int fieldIndex, Comparison operator, double value)
          Adds a HAVING clause to a SELECT statement with OR.
 void orHaving(int fieldIndex, Comparison operator, float value)
          Adds a HAVING clause to a SELECT statement with OR.
 void orHaving(int fieldIndex, Comparison operator, int value)
          Adds a HAVING clause to a SELECT statement with OR.
 void orHaving(int fieldIndex, Comparison operator, short value)
          Adds a HAVING clause to a SELECT statement with OR.
 void orHaving(int fieldIndex, Comparison operator, java.lang.String value)
          Adds a HAVING clause to a SELECT statement with OR.
 void orHaving(java.lang.String havingStatement)
          Adds a HAVING clause to a SELECT statement with OR.
 void orHaving(java.lang.String fieldName, Comparison operator, boolean value)
          Adds a HAVING clause to a SELECT statement with OR.
 void orHaving(java.lang.String fieldName, Comparison operator, byte value)
          Adds a HAVING clause to a SELECT statement with OR.
 void orHaving(java.lang.String fieldName, Comparison operator, java.util.Date value)
          Adds a HAVING clause to a SELECT statement with OR.
 void orHaving(java.lang.String fieldName, Comparison operator, double value)
          Adds a HAVING clause to a SELECT statement with OR.
 void orHaving(java.lang.String fieldName, Comparison operator, float value)
          Adds a HAVING clause to a SELECT statement with OR.
 void orHaving(java.lang.String fieldName, Comparison operator, int value)
          Adds a HAVING clause to a SELECT statement with OR.
 void orHaving(java.lang.String fieldName, Comparison operator, short value)
          Adds a HAVING clause to a SELECT statement with OR.
 void orHaving(java.lang.String fieldName, Comparison operator, java.lang.String value)
          Adds a HAVING clause to a SELECT statement with OR.
 void orWhere(int fieldIndex, Comparison operator, boolean value)
          Adds a WHERE clause to an SQL statement with OR.
 void orWhere(int fieldIndex, Comparison operator, byte value)
          Adds a WHERE clause to an SQL statement with OR.
 void orWhere(int fieldIndex, Comparison operator, java.util.Date value)
          Adds a WHERE clause to an SQL statement with OR.
 void orWhere(int fieldIndex, Comparison operator, double value)
          Adds a WHERE clause to an SQL statement with OR.
 void orWhere(int fieldIndex, Comparison operator, float value)
          Adds a WHERE clause to an SQL statement with OR.
 void orWhere(int fieldIndex, Comparison operator, int value)
          Adds a WHERE clause to an SQL statement with OR.
 void orWhere(int fieldIndex, Comparison operator, short value)
          Adds a WHERE clause to an SQL statement with OR.
 void orWhere(int fieldIndex, Comparison operator, java.lang.String value)
          Adds a WHERE clause to an SQL statement with OR.
 void orWhere(java.lang.String whereStatement)
          Adds a WHERE clause to an SQL statement with OR.
 void orWhere(java.lang.String fieldName, Comparison operator, boolean value)
          Adds a WHERE clause to an SQL statement with OR.
 void orWhere(java.lang.String fieldName, Comparison operator, byte value)
          Adds a WHERE clause to an SQL statement with OR.
 void orWhere(java.lang.String fieldName, Comparison operator, java.util.Date value)
          Adds a WHERE clause to an SQL statement with OR.
 void orWhere(java.lang.String fieldName, Comparison operator, double value)
          Adds a WHERE clause to an SQL statement with OR.
 void orWhere(java.lang.String fieldName, Comparison operator, float value)
          Adds a WHERE clause to an SQL statement with OR.
 void orWhere(java.lang.String fieldName, Comparison operator, int value)
          Adds a WHERE clause to an SQL statement with OR.
 void orWhere(java.lang.String fieldName, Comparison operator, short value)
          Adds a WHERE clause to an SQL statement with OR.
 void orWhere(java.lang.String fieldName, Comparison operator, java.lang.String value)
          Adds a WHERE clause to an SQL statement with OR.
 void prependField(int fieldIndex, java.lang.String tableName)
          Prepends the field name with a table name.
 java.lang.String selectByIdStatement(int idToSelect)
          Creates a SELECT statement based on supplied values.
 java.lang.String selectStatement()
          Creates a SELECT statement based on supplied values.
 void setFieldList(java.lang.String[] fields)
          Establishes fields.
 void setFieldList(java.lang.String[] fields, int idFieldIndex)
          Establishes fields and identity field.
 void setFieldList(java.lang.String[] fields, java.lang.String idField)
          Establishes fields and identity field.
 void setFieldProperties(int fieldIndex, java.lang.String fieldProperties)
          Sets properties of a field for CREATE TABLE statements.
 void setFieldValue(int fieldIndex, boolean fieldValue)
          Sets value of field for UPDATE and INSERT statements.
 void setFieldValue(int fieldIndex, byte fieldValue)
          Sets value of field for UPDATE and INSERT statements.
 void setFieldValue(int fieldIndex, java.util.Date fieldValue)
          Sets value of field for UPDATE and INSERT statements.
 void setFieldValue(int fieldIndex, Datum fieldValue)
          Sets value of field for UPDATE and INSERT statements.
 void setFieldValue(int fieldIndex, double fieldValue)
          Sets value of field for UPDATE and INSERT statements.
 void setFieldValue(int fieldIndex, float fieldValue)
          Sets value of field for UPDATE and INSERT statements.
 void setFieldValue(int fieldIndex, int fieldValue)
          Sets value of field for UPDATE and INSERT statements.
 void setFieldValue(int fieldIndex, long fieldValue)
          Sets value of field for UPDATE and INSERT statements.
 void setFieldValue(int fieldIndex, java.lang.Object fieldValue)
          Sets value of field for UPDATE and INSERT statements.
 void setFieldValue(int fieldIndex, short fieldValue)
          Sets value of field for UPDATE and INSERT statements.
 void setFieldValue(int fieldIndex, java.lang.String fieldValue)
          Sets value of field for UPDATE and INSERT statements.
 void setFieldValueToNull(int fieldIndex)
          Sets value of field for UPDATE and INSERT statements to NULL.
 void setTable(java.lang.String table)
          Establishes table.
 java.lang.String updateByIdStatement(int idToUpdate)
          Creates an UPDATE statement based on supplied values.
 java.lang.String updateStatement()
          Creates an UPDATE statement based on supplied values.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SqlBuilder

public SqlBuilder(java.lang.String table,
                  java.lang.String[] fields,
                  java.lang.String[] fieldProperties,
                  int idFieldIndex)
Constructor that establishes table, fields, field properties and identity field.

Parameters:
table - string name of the table in the database
fields - array of strings representing each field
fieldProperties - array of strings representing fieldProperties
idFieldIndex - zero-based ordinal position of field in fields[]

SqlBuilder

public SqlBuilder(java.lang.String table,
                  java.lang.String[] fields,
                  int idFieldIndex)
Constructor that establishes table, fields, and identity field.

Parameters:
table - string name of the table in the database
fields - array of strings representing each field
idFieldIndex - zero-based ordinal position of field in fields[]

SqlBuilder

public SqlBuilder(java.lang.String table,
                  java.lang.String[] fields,
                  java.lang.String idField)
Constructor that establishes table, fields, and identity field.

Parameters:
table - string name of the table in the database
fields - array of strings representing each field
idField - name of identity field

SqlBuilder

public SqlBuilder(java.lang.String table,
                  java.lang.String[] fields)
Constructor that establishes table and fields.

Parameters:
table - string name of the table in the database
fields - array of strings representing each field

SqlBuilder

public SqlBuilder(java.lang.String table)
Constructor that establishes table. After instantiation, setFieldList must be called to populate field list and/or identity field.

Parameters:
table - string name of the table in the database

SqlBuilder

public SqlBuilder()
Constructor that does not establish table, fields or identity field.

Method Detail

setFieldList

public void setFieldList(java.lang.String[] fields,
                         int idFieldIndex)
Establishes fields and identity field.

Parameters:
fields - array of strings representing each field
idFieldIndex - zero-based ordinal position of field in fields[]

setFieldList

public void setFieldList(java.lang.String[] fields,
                         java.lang.String idField)
Establishes fields and identity field.

Parameters:
fields - array of strings representing each field
idField - name of identity field

setFieldList

public void setFieldList(java.lang.String[] fields)
Establishes fields.

Parameters:
fields - array of strings representing each field

getFieldList

public java.lang.String[] getFieldList()
Returns array of strings representing field names already established.

Returns:
fields as array of strings

addField

public void addField(java.lang.String fieldName)
Adds a single field to the field list.

Parameters:
fieldName - the name of the field to add

prependField

public void prependField(int fieldIndex,
                         java.lang.String tableName)
Prepends the field name with a table name. This is used to differentiate fields from different tables that have the same name in queries that joins those tables.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList)
tableName - name of the table to which the field belongs

setTable

public void setTable(java.lang.String table)
Establishes table.

Parameters:
table - string representing table name

getTable

public java.lang.String getTable()
Returns string representing table name already established.

Returns:
table name as string

setFieldValue

public void setFieldValue(int fieldIndex,
                          byte fieldValue)
Sets value of field for UPDATE and INSERT statements.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList)
fieldValue - value of field as byte

setFieldValue

public void setFieldValue(int fieldIndex,
                          double fieldValue)
Sets value of field for UPDATE and INSERT statements.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList)
fieldValue - value of field as double

setFieldValue

public void setFieldValue(int fieldIndex,
                          float fieldValue)
Sets value of field for UPDATE and INSERT statements.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList)
fieldValue - value of field as float

setFieldValue

public void setFieldValue(int fieldIndex,
                          long fieldValue)
Sets value of field for UPDATE and INSERT statements.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList)
fieldValue - value of field as long

setFieldValue

public void setFieldValue(int fieldIndex,
                          short fieldValue)
Sets value of field for UPDATE and INSERT statements.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList)
fieldValue - value of field as short

setFieldValue

public void setFieldValue(int fieldIndex,
                          boolean fieldValue)
Sets value of field for UPDATE and INSERT statements.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList)
fieldValue - value of field as boolean

setFieldValue

public void setFieldValue(int fieldIndex,
                          java.util.Date fieldValue)
Sets value of field for UPDATE and INSERT statements.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList)
fieldValue - value of field as java.util.Date

setFieldValue

public void setFieldValue(int fieldIndex,
                          int fieldValue)
Sets value of field for UPDATE and INSERT statements.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList)
fieldValue - value of field as int

setFieldValueToNull

public void setFieldValueToNull(int fieldIndex)
Sets value of field for UPDATE and INSERT statements to NULL.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList)

setFieldValue

public void setFieldValue(int fieldIndex,
                          java.lang.String fieldValue)
Sets value of field for UPDATE and INSERT statements.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList)
fieldValue - value of field as java.lang.String

setFieldValue

public void setFieldValue(int fieldIndex,
                          java.lang.Object fieldValue)
Sets value of field for UPDATE and INSERT statements.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList)
fieldValue - value of field as java.lang.String

setFieldValue

public void setFieldValue(int fieldIndex,
                          Datum fieldValue)
Sets value of field for UPDATE and INSERT statements.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList)
fieldValue - value of field as java.lang.String

setFieldProperties

public void setFieldProperties(int fieldIndex,
                               java.lang.String fieldProperties)
Sets properties of a field for CREATE TABLE statements.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList)
fieldProperties - properties of field as java.lang.String

andWhere

public void andWhere(int fieldIndex,
                     Comparison operator,
                     java.lang.String value)
Adds a WHERE clause to an SQL statement with AND.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - string representing value to compare to field

andWhere

public void andWhere(java.lang.String fieldName,
                     Comparison operator,
                     java.lang.String value)
Adds a WHERE clause to an SQL statement with AND.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - string representing value to compare to field

andWhere

public void andWhere(int fieldIndex,
                     Comparison operator,
                     int value)
Adds a WHERE clause to an SQL statement with AND.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - int representing value to compare to field

andWhere

public void andWhere(java.lang.String fieldName,
                     Comparison operator,
                     int value)
Adds a WHERE clause to an SQL statement with AND.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - int representing value to compare to field

andWhere

public void andWhere(int fieldIndex,
                     Comparison operator,
                     java.util.Date value)
Adds a WHERE clause to an SQL statement with AND.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - java.util.Date representing value to compare to field

andWhere

public void andWhere(java.lang.String fieldName,
                     Comparison operator,
                     java.util.Date value)
Adds a WHERE clause to an SQL statement with AND.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - java.util.Date representing value to compare to field

andWhere

public void andWhere(int fieldIndex,
                     Comparison operator,
                     boolean value)
Adds a WHERE clause to an SQL statement with AND.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - boolean representing value to compare to field

andWhere

public void andWhere(java.lang.String fieldName,
                     Comparison operator,
                     boolean value)
Adds a WHERE clause to an SQL statement with AND.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - boolean representing value to compare to field

andWhere

public void andWhere(int fieldIndex,
                     Comparison operator,
                     short value)
Adds a WHERE clause to an SQL statement with AND.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - short representing value to compare to field

andWhere

public void andWhere(java.lang.String fieldName,
                     Comparison operator,
                     short value)
Adds a WHERE clause to an SQL statement with AND.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - short representing value to compare to field

andWhere

public void andWhere(int fieldIndex,
                     Comparison operator,
                     float value)
Adds a WHERE clause to an SQL statement with AND.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - float representing value to compare to field

andWhere

public void andWhere(java.lang.String fieldName,
                     Comparison operator,
                     float value)
Adds a WHERE clause to an SQL statement with AND.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - float representing value to compare to field

andWhere

public void andWhere(int fieldIndex,
                     Comparison operator,
                     double value)
Adds a WHERE clause to an SQL statement with AND.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - double representing value to compare to field

andWhere

public void andWhere(java.lang.String fieldName,
                     Comparison operator,
                     double value)
Adds a WHERE clause to an SQL statement with AND.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - double representing value to compare to field

andWhere

public void andWhere(int fieldIndex,
                     Comparison operator,
                     byte value)
Adds a WHERE clause to an SQL statement with AND.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - byte representing value to compare to field

andWhere

public void andWhere(java.lang.String fieldName,
                     Comparison operator,
                     byte value)
Adds a WHERE clause to an SQL statement with AND.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - byte representing value to compare to field

andWhere

public void andWhere(java.lang.String whereStatement)
Adds a WHERE clause to an SQL statement with AND.

Parameters:
whereStatement - string containing complete WHERE clause

orWhere

public void orWhere(int fieldIndex,
                    Comparison operator,
                    java.lang.String value)
Adds a WHERE clause to an SQL statement with OR.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - string representing value to compare to field

orWhere

public void orWhere(java.lang.String fieldName,
                    Comparison operator,
                    java.lang.String value)
Adds a WHERE clause to an SQL statement with OR.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - string representing value to compare to field

orWhere

public void orWhere(int fieldIndex,
                    Comparison operator,
                    int value)
Adds a WHERE clause to an SQL statement with OR.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - int representing value to compare to field

orWhere

public void orWhere(java.lang.String fieldName,
                    Comparison operator,
                    int value)
Adds a WHERE clause to an SQL statement with OR.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - int representing value to compare to field

orWhere

public void orWhere(int fieldIndex,
                    Comparison operator,
                    java.util.Date value)
Adds a WHERE clause to an SQL statement with OR.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - java.util.Date representing value to compare to field

orWhere

public void orWhere(java.lang.String fieldName,
                    Comparison operator,
                    java.util.Date value)
Adds a WHERE clause to an SQL statement with OR.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - java.util.Date representing value to compare to field

orWhere

public void orWhere(int fieldIndex,
                    Comparison operator,
                    boolean value)
Adds a WHERE clause to an SQL statement with OR.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - boolean representing value to compare to field

orWhere

public void orWhere(java.lang.String fieldName,
                    Comparison operator,
                    boolean value)
Adds a WHERE clause to an SQL statement with OR.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - boolean representing value to compare to field

orWhere

public void orWhere(int fieldIndex,
                    Comparison operator,
                    short value)
Adds a WHERE clause to an SQL statement with OR.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - short representing value to compare to field

orWhere

public void orWhere(java.lang.String fieldName,
                    Comparison operator,
                    short value)
Adds a WHERE clause to an SQL statement with OR.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - short representing value to compare to field

orWhere

public void orWhere(int fieldIndex,
                    Comparison operator,
                    float value)
Adds a WHERE clause to an SQL statement with OR.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - float representing value to compare to field

orWhere

public void orWhere(java.lang.String fieldName,
                    Comparison operator,
                    float value)
Adds a WHERE clause to an SQL statement with OR.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - float representing value to compare to field

orWhere

public void orWhere(int fieldIndex,
                    Comparison operator,
                    double value)
Adds a WHERE clause to an SQL statement with OR.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - double representing value to compare to field

orWhere

public void orWhere(java.lang.String fieldName,
                    Comparison operator,
                    double value)
Adds a WHERE clause to an SQL statement with OR.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - double representing value to compare to field

orWhere

public void orWhere(int fieldIndex,
                    Comparison operator,
                    byte value)
Adds a WHERE clause to an SQL statement with OR.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - byte representing value to compare to field

orWhere

public void orWhere(java.lang.String fieldName,
                    Comparison operator,
                    byte value)
Adds a WHERE clause to an SQL statement with OR.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - byte representing value to compare to field

orWhere

public void orWhere(java.lang.String whereStatement)
Adds a WHERE clause to an SQL statement with OR.

Parameters:
whereStatement - string containing complete WHERE clause

join

public void join(java.lang.String tableToJoin,
                 java.lang.String fieldInFirstTable,
                 java.lang.String fieldInTableToJoin)
Adds an INNER JOIN clause to an SQL statement.

Parameters:
tableToJoin - name of the table to join
fieldInFirstTable - name of field in first table
fieldInTableToJoin - name of field in table specified in tableToJoin

join

public void join(java.lang.String tableToJoin,
                 java.lang.String fieldInFirstTable,
                 Comparison operator,
                 java.lang.String fieldInTableToJoin)
Adds an INNER JOIN clause to an SQL statement.

Parameters:
tableToJoin - name of the table to join
fieldInFirstTable - name of field in first table
operator - comparison operator for join
fieldInTableToJoin - name of field in table specified in tableToJoin

join

public void join(java.lang.String tableToJoin,
                 java.lang.String onStatement)
Adds an INNER JOIN clause to an SQL statement.

Parameters:
tableToJoin - name of the table to join
onStatement - conditional statement to define the join

join

public void join(JoinType joinType,
                 java.lang.String tableToJoin,
                 java.lang.String fieldInFirstTable,
                 Comparison operator,
                 java.lang.String fieldInTableToJoin)
Adds a JOIN clause to an SQL statement.

Parameters:
joinType - the type of join to add
tableToJoin - name of the table to join
fieldInFirstTable - name of field in first table
operator - comparison operator for join
fieldInTableToJoin - name of field in table specified in tableToJoin

join

public void join(JoinType joinType,
                 java.lang.String tableToJoin,
                 java.lang.String onStatement)
Adds a JOIN clause to an SQL statement.

Parameters:
joinType - the type of join to add
tableToJoin - name of the table to join
onStatement - conditional statement to define the join

groupBy

public void groupBy(int groupByFieldIndex)
Adds a GROUP BY clause to a SELECT statement.

Parameters:
groupByFieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to group by

groupBy

public void groupBy(java.lang.String groupByField)
Adds a GROUP BY clause to a SELECT statement.

Parameters:
groupByField - string name of field to group by

andHaving

public void andHaving(int fieldIndex,
                      Comparison operator,
                      java.lang.String value)
Adds a HAVING clause to a SELECT statement with AND.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - string representing value to compare to field

andHaving

public void andHaving(java.lang.String fieldName,
                      Comparison operator,
                      java.lang.String value)
Adds a HAVING clause to a SELECT statement with AND.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - string representing value to compare to field

andHaving

public void andHaving(int fieldIndex,
                      Comparison operator,
                      int value)
Adds a HAVING clause to a SELECT statement with AND.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - int representing value to compare to field

andHaving

public void andHaving(java.lang.String fieldName,
                      Comparison operator,
                      int value)
Adds a HAVING clause to a SELECT statement with AND.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - int representing value to compare to field

andHaving

public void andHaving(int fieldIndex,
                      Comparison operator,
                      java.util.Date value)
Adds a HAVING clause to a SELECT statement with AND.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - java.util.Date representing value to compare to field

andHaving

public void andHaving(java.lang.String fieldName,
                      Comparison operator,
                      java.util.Date value)
Adds a HAVING clause to a SELECT statement with AND.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - java.util.Date representing value to compare to field

andHaving

public void andHaving(int fieldIndex,
                      Comparison operator,
                      boolean value)
Adds a HAVING clause to a SELECT statement with AND.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - boolean representing value to compare to field

andHaving

public void andHaving(java.lang.String fieldName,
                      Comparison operator,
                      boolean value)
Adds a HAVING clause to a SELECT statement with AND.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - boolean representing value to compare to field

andHaving

public void andHaving(int fieldIndex,
                      Comparison operator,
                      short value)
Adds a HAVING clause to a SELECT statement with AND.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - short representing value to compare to field

andHaving

public void andHaving(java.lang.String fieldName,
                      Comparison operator,
                      short value)
Adds a HAVING clause to a SELECT statement with AND.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - short representing value to compare to field

andHaving

public void andHaving(int fieldIndex,
                      Comparison operator,
                      float value)
Adds a HAVING clause to a SELECT statement with AND.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - float representing value to compare to field

andHaving

public void andHaving(java.lang.String fieldName,
                      Comparison operator,
                      float value)
Adds a HAVING clause to a SELECT statement with AND.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - float representing value to compare to field

andHaving

public void andHaving(int fieldIndex,
                      Comparison operator,
                      double value)
Adds a HAVING clause to a SELECT statement with AND.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - double representing value to compare to field

andHaving

public void andHaving(java.lang.String fieldName,
                      Comparison operator,
                      double value)
Adds a HAVING clause to a SELECT statement with AND.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - double representing value to compare to field

andHaving

public void andHaving(int fieldIndex,
                      Comparison operator,
                      byte value)
Adds a HAVING clause to a SELECT statement with AND.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - byte representing value to compare to field

andHaving

public void andHaving(java.lang.String fieldName,
                      Comparison operator,
                      byte value)
Adds a HAVING clause to a SELECT statement with AND.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - byte representing value to compare to field

andHaving

public void andHaving(java.lang.String havingStatement)
Adds a HAVING clause to a SELECT statement with AND.

Parameters:
havingStatement - string containing complete HAVING clause

orHaving

public void orHaving(int fieldIndex,
                     Comparison operator,
                     java.lang.String value)
Adds a HAVING clause to a SELECT statement with OR.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - string representing value to compare to field

orHaving

public void orHaving(java.lang.String fieldName,
                     Comparison operator,
                     java.lang.String value)
Adds a HAVING clause to a SELECT statement with OR.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - string representing value to compare to field

orHaving

public void orHaving(int fieldIndex,
                     Comparison operator,
                     int value)
Adds a HAVING clause to a SELECT statement with OR.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - int representing value to compare to field

orHaving

public void orHaving(java.lang.String fieldName,
                     Comparison operator,
                     int value)
Adds a HAVING clause to a SELECT statement with OR.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - int representing value to compare to field

orHaving

public void orHaving(int fieldIndex,
                     Comparison operator,
                     java.util.Date value)
Adds a HAVING clause to a SELECT statement with OR.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - java.util.Date representing value to compare to field

orHaving

public void orHaving(java.lang.String fieldName,
                     Comparison operator,
                     java.util.Date value)
Adds a HAVING clause to a SELECT statement with OR.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - java.util.Date representing value to compare to field

orHaving

public void orHaving(int fieldIndex,
                     Comparison operator,
                     boolean value)
Adds a HAVING clause to a SELECT statement with OR.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - boolean representing value to compare to field

orHaving

public void orHaving(java.lang.String fieldName,
                     Comparison operator,
                     boolean value)
Adds a HAVING clause to a SELECT statement with OR.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - boolean representing value to compare to field

orHaving

public void orHaving(int fieldIndex,
                     Comparison operator,
                     short value)
Adds a HAVING clause to a SELECT statement with OR.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - short representing value to compare to field

orHaving

public void orHaving(java.lang.String fieldName,
                     Comparison operator,
                     short value)
Adds a HAVING clause to a SELECT statement with OR.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - short representing value to compare to field

orHaving

public void orHaving(int fieldIndex,
                     Comparison operator,
                     float value)
Adds a HAVING clause to a SELECT statement with OR.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - float representing value to compare to field

orHaving

public void orHaving(java.lang.String fieldName,
                     Comparison operator,
                     float value)
Adds a HAVING clause to a SELECT statement with OR.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - float representing value to compare to field

orHaving

public void orHaving(int fieldIndex,
                     Comparison operator,
                     double value)
Adds a HAVING clause to a SELECT statement with OR.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - double representing value to compare to field

orHaving

public void orHaving(java.lang.String fieldName,
                     Comparison operator,
                     double value)
Adds a HAVING clause to a SELECT statement with OR.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - double representing value to compare to field

orHaving

public void orHaving(int fieldIndex,
                     Comparison operator,
                     byte value)
Adds a HAVING clause to a SELECT statement with OR.

Parameters:
fieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - byte representing value to compare to field

orHaving

public void orHaving(java.lang.String fieldName,
                     Comparison operator,
                     byte value)
Adds a HAVING clause to a SELECT statement with OR.

Parameters:
fieldName - string name of field to test versus supplied value.
operator - Comparison representing the type of comparison operation
value - byte representing value to compare to field

orHaving

public void orHaving(java.lang.String havingStatement)
Adds a HAVING clause to a SELECT statement with OR.

Parameters:
havingStatement - string containing complete HAVING clause

orderByAscending

public void orderByAscending(int orderByFieldIndex)
Adds an ORDER BY clause to a SELECT statement with ASC as the direction.

Parameters:
orderByFieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to sort by

orderByAscending

public void orderByAscending(java.lang.String orderByField)
Adds a ORDER BY clause to a SELECT statement with ASC as the direction.

Parameters:
orderByField - string name of field to sort by

orderByDescending

public void orderByDescending(java.lang.String orderByField)
Adds a ORDER BY clause to a SELECT statement with DESC as the direction.

Parameters:
orderByField - string name of field to sort by

orderByDescending

public void orderByDescending(int orderByFieldIndex)
Adds an ORDER BY clause to a SELECT statement with DESC as the direction.

Parameters:
orderByFieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to sort by

orderBy

public void orderBy(int orderByFieldIndex,
                    OrderDirection direction)
Adds an ORDER BY clause to a SELECT statement with direction as the direction.

Parameters:
orderByFieldIndex - ordinal position of field in fields[] (as defined in constructor or setFieldList) to sort by

orderBy

public void orderBy(java.lang.String orderByField,
                    OrderDirection direction)
Adds a ORDER BY clause to a SELECT statement with direction as the direction.

Parameters:
orderByField - string name of field to sort by

selectByIdStatement

public java.lang.String selectByIdStatement(int idToSelect)
Creates a SELECT statement based on supplied values.

Parameters:
idToSelect - int representing identity value of specific record to return
Returns:
SQL SELECT statement

selectStatement

public java.lang.String selectStatement()
Creates a SELECT statement based on supplied values.

Returns:
SQL SELECT statement

insertStatement

public java.lang.String insertStatement()
Creates a INSERT statement based on supplied values.

Returns:
SQL INSERT statement

updateByIdStatement

public java.lang.String updateByIdStatement(int idToUpdate)
Creates an UPDATE statement based on supplied values.

Parameters:
idToUpdate - int representing identity value of specific record to update
Returns:
SQL UPDATE statement

updateStatement

public java.lang.String updateStatement()
Creates an UPDATE statement based on supplied values.

Returns:
SQL UPDATE statement

createTableStatement

public java.lang.String createTableStatement()
Creates a CREATE TABLE statement based on supplied values.

Returns:
SQL CREATE TABLE statement

deleteByIdStatement

public java.lang.String deleteByIdStatement(int idToDelete)
Creates an DELETE statement based on supplied values.

Parameters:
idToDelete - int representing identity value of specific record to delete
Returns:
SQL DELETE statement

deleteStatement

public java.lang.String deleteStatement()
Creates an DELETE statement based on supplied values.

Returns:
SQL DELETE statement

encode

public static java.lang.String encode(java.lang.String toEncode)
Modifies a string so it will be processed as a complete string within SQL.

Parameters:
toEncode - the string to encode
Returns:
the encoded string