com.hardcode.gdbms.engine.data
Class InnerDBUtils

java.lang.Object
  extended by com.hardcode.gdbms.engine.data.InnerDBUtils

public class InnerDBUtils
extends java.lang.Object

Utility class to generate SQL statements

Author:
Fernando González Cortés

Constructor Summary
InnerDBUtils()
           
 
Method Summary
static java.lang.String buildSQLWhere(java.lang.String[] pks, java.lang.String[] fieldNames)
          Builds a WHERE clause with the and operation of the equality between each field name and field value
static java.lang.String createDeleteStatement(Value[] pks, java.lang.String[] names, java.lang.String tableName, ValueWriter vWriter)
          Creates a delete statement in the specified table in the row specified by the field names and field values
static java.lang.String createInsertStatement(java.lang.String tableName, Value[] row, java.lang.String[] fieldNames, ValueWriter vWriter)
          Creates a new Insert statement in the specified table with the specified values for the corresponding field names
static java.lang.String createUpdateStatement(java.lang.String tableName, Value[] pk, java.lang.String[] pkNames, java.lang.String[] fieldNames, Value[] values, ValueWriter vWriter)
          creates an update statement in the specified table
static void execute(java.lang.String database, java.lang.String sql)
          DOCUMENT ME!
static java.lang.String getCreateStatementWithAutonumeric(java.lang.String tableName, java.lang.String[] names, int[] types)
          Creates a SQL statement to create a table.
static java.lang.String getCreateStatementWithPK(java.lang.String tableName, java.lang.String[] pkNames, java.lang.String[] names, int[] types)
          Creates a SQL statement to create a table.
static java.lang.String getPKIndexStatement(java.lang.String tableName, java.lang.String[] pkNames)
          Creates a create index statement
static java.lang.String getTypeString(int type)
          Gets the name of the type to be used with the internal dbms
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InnerDBUtils

public InnerDBUtils()
Method Detail

buildSQLWhere

public static java.lang.String buildSQLWhere(java.lang.String[] pks,
                                             java.lang.String[] fieldNames)
Builds a WHERE clause with the and operation of the equality between each field name and field value

Parameters:
pks - String array with the field values
fieldNames - String array with the field names
Returns:
String

createDeleteStatement

public static java.lang.String createDeleteStatement(Value[] pks,
                                                     java.lang.String[] names,
                                                     java.lang.String tableName,
                                                     ValueWriter vWriter)
Creates a delete statement in the specified table in the row specified by the field names and field values

Parameters:
pks - values to specify the row to delete
names - names of the fields
tableName - name of the table
vWriter - DOCUMENT ME!
Returns:
String

getCreateStatementWithAutonumeric

public static java.lang.String getCreateStatementWithAutonumeric(java.lang.String tableName,
                                                                 java.lang.String[] names,
                                                                 int[] types)
Creates a SQL statement to create a table. Creates an aditional field called GDBMSINDEX with the autonumeric primary key constraint

Parameters:
tableName - Name of the table to be created
names - names of the fields
types - types of the fields. Must have the same length than names
Returns:
SQL statement

getCreateStatementWithPK

public static java.lang.String getCreateStatementWithPK(java.lang.String tableName,
                                                        java.lang.String[] pkNames,
                                                        java.lang.String[] names,
                                                        int[] types)
Creates a SQL statement to create a table.

Parameters:
tableName - Name of the table to be created
pkNames - DOCUMENT ME!
names - names of the fields
types - types of the fields. Must have the same length than names
Returns:
SQL statement

getPKIndexStatement

public static java.lang.String getPKIndexStatement(java.lang.String tableName,
                                                   java.lang.String[] pkNames)
Creates a create index statement

Parameters:
tableName - table where the index will be created
pkNames - name of the fields where the index will be created
Returns:
String

getTypeString

public static java.lang.String getTypeString(int type)
Gets the name of the type to be used with the internal dbms

Parameters:
type - java.sql.Types constant
Returns:
String
Throws:
java.lang.RuntimeException - If the Type is not recognized

createInsertStatement

public static java.lang.String createInsertStatement(java.lang.String tableName,
                                                     Value[] row,
                                                     java.lang.String[] fieldNames,
                                                     ValueWriter vWriter)
Creates a new Insert statement in the specified table with the specified values for the corresponding field names

Parameters:
tableName - table name
row - values to be inserted
fieldNames - names of the fields to be inserted
vWriter - DOCUMENT ME!
Returns:
String

execute

public static void execute(java.lang.String database,
                           java.lang.String sql)
                    throws java.sql.SQLException
DOCUMENT ME!

Parameters:
database - DOCUMENT ME!
sql - DOCUMENT ME!
Throws:
java.sql.SQLException - DOCUMENT ME!

createUpdateStatement

public static java.lang.String createUpdateStatement(java.lang.String tableName,
                                                     Value[] pk,
                                                     java.lang.String[] pkNames,
                                                     java.lang.String[] fieldNames,
                                                     Value[] values,
                                                     ValueWriter vWriter)
creates an update statement in the specified table

Parameters:
tableName - table name
pk - values of the primary key
pkNames - name of the primary key fields
fieldNames - name of all fields
values - values to be updated
vWriter - DOCUMENT ME!
Returns:
String


Copyright © 2005-2006 . All Rights Reserved.