org.apache.ws.jaxme.sqls.impl

Class SQLFactoryImpl

Implemented Interfaces:
SQLFactory
Known Direct Subclasses:
DB2SQLFactoryImpl, HsqlDbSQLFactoryImpl, OraSQLFactoryImpl

public class SQLFactoryImpl
extends java.lang.Object
implements SQLFactory

Default implementation of an SQLFactory.
Author:
Jochen Wiedmann

Nested Class Summary

static class
SQLFactoryImpl.IdentImpl
Base class for deriving identifiers.

Constructor Summary

SQLFactoryImpl()
Creates a new instance of SQLFactoryImpl.

Method Summary

Schema
getDefaultSchema()
Returns the Default schema.
Integer
getMaxColumnNameLength()
Returns the maximum length of a column name.
Integer
getMaxSchemaNameLength()
Returns the maximum length of a schema name.
Integer
getMaxTableNameLength()
Returns the maximum length of a table name.
ObjectFactory
getObjectFactory()
Returns the object factory being used.
Schema
getSchema(Connection pConn, String pName)
Reads the schema named pName from the database.
Schema
getSchema(Connection pConn, Schema.Name pName)
Reads the schema named pName from the database.
Schema
getSchema(String pName)
Returns the schema with the given name or null, if no such schema exists.
Schema
getSchema(Schema.Name pName)
Returns the schema with the given name or null, if no such schema exists.
Iterator
getSchemas()
Returns a list of all schemas.
Table
getTable(Connection pConnection, String pSchema, String pTable)
Reads the table named pTable from the schema named pSchema in the database.
Table
getTable(Connection pConnection, Schema.Name pSchema, Table.Name pTable)
Reads the table named pTable from the schema named pSchema in the database.
boolean
isColumnNameCaseSensitive()
Returns whether column names are case sensitive or not.
boolean
isSchemaNameCaseSensitive()
Returns whether schema names are case sensitive or not.
boolean
isTableNameCaseSensitive()
Returns whether table names are case sensitive or not.
protected Schema
makeSchema(Schema.Name pName)
protected Column
newColumnImpl(Table pTable, Column.Name pName, Column.Type pType)
DeleteStatement
newDeleteStatement()
Creates a new DELETE statement.
SQLFactory.Ident
newIdent(String pName)
Converths the given string into an SQL identifier.
InsertStatement
newInsertStatement()
Creates a new INSERT statement.
protected ObjectFactory
newObjectFactory()
SQLGenerator
newSQLGenerator()
Creates a new SQLGenerator.
Schema
newSchema(String pName)
Creates a new Schema with the given name.
Schema
newSchema(Schema.Name pName)
Creates a new Schema with the given name.
protected Schema
newSchemaImpl(Schema.Name pName)
SelectStatement
newSelectStatement()
Creates a new SELECT statement.
protected Table
newTableImpl(Schema pSchema, Table.Name pName)
UpdateStatement
newUpdateStatement()
Creates a new UPDATE statement.
protected Column
readColumn(Table pTable, String pColumnName, int pDataType, String pTypeName, long pColumnSize, int pDecimalDigits, int pNullable)
protected ForeignKey[]
readForeignKeys(DatabaseMetaData pData, org.apache.ws.jaxme.sqls.impl.SQLFactoryImpl.JDBCTable pTable, org.apache.ws.jaxme.sqls.impl.SQLFactoryImpl.JDBCTable[] pTables)
protected Index
readPrimaryKey(DatabaseMetaData pData, org.apache.ws.jaxme.sqls.impl.SQLFactoryImpl.JDBCTable pTable)
protected Table
readTable(DatabaseMetaData pData, Schema pSchema, org.apache.ws.jaxme.sqls.impl.SQLFactoryImpl.JDBCTable pTable)
protected org.apache.ws.jaxme.sqls.impl.SQLFactoryImpl.JDBCTable[]
readTables(DatabaseMetaData pData, Schema.Name pSchema, Table.Name pTable)
void
setColumnNameCaseSensitive(boolean pColumnNameCaseSensitive)
Sets whether column names are case sensitive or not.
void
setMaxColumnNameLength(Integer pMaxLength)
Sets the maximum length of a column name.
void
setMaxSchemaNameLength(Integer pMaxLength)
Sets the maximum length of a schema name.
void
setMaxTableNameLength(Integer pMaxLength)
Sets the maximum length of a table name.
protected void
setObjectFactory(ObjectFactory pFactory)
void
setSchemaNameCaseSensitive(boolean pSchemaNameCaseSensitive)
Sets whether schema names are case sensitive or not.
void
setTableNameCaseSensitive(boolean pTableNameCaseSensitive)
Sets whether table names are case sensitive or not.

Constructor Details

SQLFactoryImpl

public SQLFactoryImpl()
Creates a new instance of SQLFactoryImpl.

Method Details

getDefaultSchema

public Schema getDefaultSchema()
Returns the Default schema. The default schema has the name null.
Specified by:
getDefaultSchema in interface SQLFactory

getMaxColumnNameLength

public Integer getMaxColumnNameLength()
Returns the maximum length of a column name.
Specified by:
getMaxColumnNameLength in interface SQLFactory
Returns:
The maximum length or null, if checks for valid column name length are disabled.

getMaxSchemaNameLength

public Integer getMaxSchemaNameLength()
Returns the maximum length of a schema name.
Specified by:
getMaxSchemaNameLength in interface SQLFactory
Returns:
The maximum length or null, if checks for valid schema name length are disabled.

getMaxTableNameLength

public Integer getMaxTableNameLength()
Returns the maximum length of a table name.
Specified by:
getMaxTableNameLength in interface SQLFactory
Returns:
The maximum length or null, if checks for valid table name length are disabled.

getObjectFactory

public ObjectFactory getObjectFactory()
Returns the object factory being used.
Specified by:
getObjectFactory in interface SQLFactory

getSchema

public Schema getSchema(Connection pConn,
                        String pName)
            throws SQLException
Reads the schema named pName from the database.
Specified by:
getSchema in interface SQLFactory

getSchema

public Schema getSchema(Connection pConn,
                        Schema.Name pName)
            throws SQLException
Reads the schema named pName from the database.
Specified by:
getSchema in interface SQLFactory

getSchema

public Schema getSchema(String pName)
Returns the schema with the given name or null, if no such schema exists.
Specified by:
getSchema in interface SQLFactory

getSchema

public Schema getSchema(Schema.Name pName)
Returns the schema with the given name or null, if no such schema exists.
Specified by:
getSchema in interface SQLFactory

getSchemas

public Iterator getSchemas()
Specified by:
getSchemas in interface SQLFactory

getTable

public Table getTable(Connection pConnection,
                      String pSchema,
                      String pTable)
            throws SQLException
Reads the table named pTable from the schema named pSchema in the database.
Specified by:
getTable in interface SQLFactory

getTable

public Table getTable(Connection pConnection,
                      Schema.Name pSchema,
                      Table.Name pTable)
            throws SQLException
Reads the table named pTable from the schema named pSchema in the database.
Specified by:
getTable in interface SQLFactory

isColumnNameCaseSensitive

public boolean isColumnNameCaseSensitive()
Returns whether column names are case sensitive or not. Defaults to false.
Specified by:
isColumnNameCaseSensitive in interface SQLFactory

isSchemaNameCaseSensitive

public boolean isSchemaNameCaseSensitive()
Returns whether schema names are case sensitive or not. Defaults to false.
Specified by:
isSchemaNameCaseSensitive in interface SQLFactory

isTableNameCaseSensitive

public boolean isTableNameCaseSensitive()
Returns whether table names are case sensitive or not. Defaults to false.
Specified by:
isTableNameCaseSensitive in interface SQLFactory

makeSchema

protected Schema makeSchema(Schema.Name pName)

newColumnImpl

protected Column newColumnImpl(Table pTable,
                               Column.Name pName,
                               Column.Type pType)

newDeleteStatement

public DeleteStatement newDeleteStatement()
Creates a new DELETE statement.
Specified by:
newDeleteStatement in interface SQLFactory

newIdent

public SQLFactory.Ident newIdent(String pName)
Converths the given string into an SQL identifier.

newInsertStatement

public InsertStatement newInsertStatement()
Creates a new INSERT statement.
Specified by:
newInsertStatement in interface SQLFactory

newObjectFactory

protected ObjectFactory newObjectFactory()

newSQLGenerator

public SQLGenerator newSQLGenerator()
Creates a new SQLGenerator.
Specified by:
newSQLGenerator in interface SQLFactory

newSchema

public Schema newSchema(String pName)
Creates a new Schema with the given name.
Specified by:
newSchema in interface SQLFactory

newSchema

public Schema newSchema(Schema.Name pName)
Creates a new Schema with the given name.
Specified by:
newSchema in interface SQLFactory

newSchemaImpl

protected Schema newSchemaImpl(Schema.Name pName)

newSelectStatement

public SelectStatement newSelectStatement()
Creates a new SELECT statement.
Specified by:
newSelectStatement in interface SQLFactory

newTableImpl

protected Table newTableImpl(Schema pSchema,
                             Table.Name pName)

newUpdateStatement

public UpdateStatement newUpdateStatement()
Creates a new UPDATE statement.
Specified by:
newUpdateStatement in interface SQLFactory

readColumn

protected Column readColumn(Table pTable,
                            String pColumnName,
                            int pDataType,
                            String pTypeName,
                            long pColumnSize,
                            int pDecimalDigits,
                            int pNullable)

readForeignKeys

protected ForeignKey[] readForeignKeys(DatabaseMetaData pData,
                                       org.apache.ws.jaxme.sqls.impl.SQLFactoryImpl.JDBCTable pTable,
                                       org.apache.ws.jaxme.sqls.impl.SQLFactoryImpl.JDBCTable[] pTables)
            throws SQLException

readPrimaryKey

protected Index readPrimaryKey(DatabaseMetaData pData,
                               org.apache.ws.jaxme.sqls.impl.SQLFactoryImpl.JDBCTable pTable)
            throws SQLException

readTable

protected Table readTable(DatabaseMetaData pData,
                          Schema pSchema,
                          org.apache.ws.jaxme.sqls.impl.SQLFactoryImpl.JDBCTable pTable)
            throws SQLException

readTables

protected org.apache.ws.jaxme.sqls.impl.SQLFactoryImpl.JDBCTable[] readTables(DatabaseMetaData pData,
                                                                              Schema.Name pSchema,
                                                                              Table.Name pTable)
            throws SQLException

setColumnNameCaseSensitive

public void setColumnNameCaseSensitive(boolean pColumnNameCaseSensitive)
Sets whether column names are case sensitive or not. Defaults to false.

setMaxColumnNameLength

public void setMaxColumnNameLength(Integer pMaxLength)
Sets the maximum length of a column name.
Parameters:
pMaxLength - The maximum length or null to disable checks for valid column name length.

setMaxSchemaNameLength

public void setMaxSchemaNameLength(Integer pMaxLength)
Sets the maximum length of a schema name.
Parameters:
pMaxLength - The maximum length or null to disable checks for valid schema name length.

setMaxTableNameLength

public void setMaxTableNameLength(Integer pMaxLength)
Sets the maximum length of a table name.
Parameters:
pMaxLength - The maximum length or null to disable checks for valid table name length.

setObjectFactory

protected void setObjectFactory(ObjectFactory pFactory)

setSchemaNameCaseSensitive

public void setSchemaNameCaseSensitive(boolean pSchemaNameCaseSensitive)
Sets whether schema names are case sensitive or not. Defaults to false.

setTableNameCaseSensitive

public void setTableNameCaseSensitive(boolean pTableNameCaseSensitive)
Sets whether table names are case sensitive or not. Defaults to false.