org.apache.ws.jaxme.sqls.impl
Class SQLFactoryImpl

java.lang.Object
  extended by org.apache.ws.jaxme.sqls.impl.SQLFactoryImpl
All Implemented Interfaces:
SQLFactory
Direct Known 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.
 
Nested classes/interfaces inherited from interface org.apache.ws.jaxme.sqls.SQLFactory
SQLFactory.Ident
 
Constructor Summary
SQLFactoryImpl()
          Creates a new instance of SQLFactoryImpl.
 
Method Summary
 Schema getDefaultSchema()
          Returns the Default schema.
 java.lang.Integer getMaxColumnNameLength()
          Returns the maximum length of a column name.
 java.lang.Integer getMaxSchemaNameLength()
          Returns the maximum length of a schema name.
 java.lang.Integer getMaxTableNameLength()
          Returns the maximum length of a table name.
 ObjectFactory getObjectFactory()
          Returns the object factory being used.
 Schema getSchema(java.sql.Connection pConn, Schema.Name pName)
          Reads the schema named pName from the database.
 Schema getSchema(java.sql.Connection pConn, java.lang.String pName)
          Reads the schema named pName from the database.
 Schema getSchema(Schema.Name pName)
          Returns the schema with the given name or null, if no such schema exists.
 Schema getSchema(java.lang.String pName)
          Returns the schema with the given name or null, if no such schema exists.
 java.util.Iterator getSchemas()
          Returns a list of all schemas.
 Table getTable(java.sql.Connection pConnection, Schema.Name pSchema, Table.Name pTable)
          Reads the table named pTable from the schema named pSchema in the database.
 Table getTable(java.sql.Connection pConnection, java.lang.String pSchema, java.lang.String 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(java.lang.String pName)
          Converths the given string into an SQL identifier.
 InsertStatement newInsertStatement()
          Creates a new INSERT statement.
protected  ObjectFactory newObjectFactory()
           
 Schema newSchema(Schema.Name pName)
          Creates a new Schema with the given name.
 Schema newSchema(java.lang.String pName)
          Creates a new Schema with the given name.
protected  Schema newSchemaImpl(Schema.Name pName)
           
 SelectStatement newSelectStatement()
          Creates a new SELECT statement.
 SQLGenerator newSQLGenerator()
          Creates a new SQLGenerator.
protected  Table newTableImpl(Schema pSchema, Table.Name pName)
           
 UpdateStatement newUpdateStatement()
          Creates a new UPDATE statement.
protected  Column readColumn(Table pTable, java.lang.String pColumnName, int pDataType, java.lang.String pTypeName, long pColumnSize, int pDecimalDigits, int pNullable)
           
protected  ForeignKey[] readForeignKeys(java.sql.DatabaseMetaData pData, org.apache.ws.jaxme.sqls.impl.SQLFactoryImpl.JDBCTable pTable, org.apache.ws.jaxme.sqls.impl.SQLFactoryImpl.JDBCTable[] pTables)
           
protected  Index readPrimaryKey(java.sql.DatabaseMetaData pData, org.apache.ws.jaxme.sqls.impl.SQLFactoryImpl.JDBCTable pTable)
           
protected  Table readTable(java.sql.DatabaseMetaData pData, Schema pSchema, org.apache.ws.jaxme.sqls.impl.SQLFactoryImpl.JDBCTable pTable)
           
protected  org.apache.ws.jaxme.sqls.impl.SQLFactoryImpl.JDBCTable[] readTables(java.sql.DatabaseMetaData pData, Schema.Name pSchema, Table.Name pTable)
           
 void setColumnNameCaseSensitive(boolean pColumnNameCaseSensitive)
          Sets whether column names are case sensitive or not.
 void setMaxColumnNameLength(java.lang.Integer pMaxLength)
          Sets the maximum length of a column name.
 void setMaxSchemaNameLength(java.lang.Integer pMaxLength)
          Sets the maximum length of a schema name.
 void setMaxTableNameLength(java.lang.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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLFactoryImpl

public SQLFactoryImpl()

Creates a new instance of SQLFactoryImpl.

Method Detail

newObjectFactory

protected ObjectFactory newObjectFactory()

getObjectFactory

public ObjectFactory getObjectFactory()
Description copied from interface: SQLFactory

Returns the object factory being used.

Specified by:
getObjectFactory in interface SQLFactory

setObjectFactory

protected void setObjectFactory(ObjectFactory pFactory)

setMaxTableNameLength

public void setMaxTableNameLength(java.lang.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.

getMaxTableNameLength

public java.lang.Integer getMaxTableNameLength()
Description copied from interface: SQLFactory

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.

setTableNameCaseSensitive

public void setTableNameCaseSensitive(boolean pTableNameCaseSensitive)

Sets whether table names are case sensitive or not. Defaults to false.

See Also:
SQLFactory.isTableNameCaseSensitive()

isTableNameCaseSensitive

public boolean isTableNameCaseSensitive()
Description copied from interface: SQLFactory

Returns whether table names are case sensitive or not. Defaults to false.

Specified by:
isTableNameCaseSensitive in interface SQLFactory

setMaxColumnNameLength

public void setMaxColumnNameLength(java.lang.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.

getMaxColumnNameLength

public java.lang.Integer getMaxColumnNameLength()
Description copied from interface: SQLFactory

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.

setColumnNameCaseSensitive

public void setColumnNameCaseSensitive(boolean pColumnNameCaseSensitive)

Sets whether column names are case sensitive or not. Defaults to false.

See Also:
SQLFactory.isColumnNameCaseSensitive()

isColumnNameCaseSensitive

public boolean isColumnNameCaseSensitive()
Description copied from interface: SQLFactory

Returns whether column names are case sensitive or not. Defaults to false.

Specified by:
isColumnNameCaseSensitive in interface SQLFactory

setSchemaNameCaseSensitive

public void setSchemaNameCaseSensitive(boolean pSchemaNameCaseSensitive)

Sets whether schema names are case sensitive or not. Defaults to false.

See Also:
SQLFactory.isSchemaNameCaseSensitive()

isSchemaNameCaseSensitive

public boolean isSchemaNameCaseSensitive()
Description copied from interface: SQLFactory

Returns whether schema names are case sensitive or not. Defaults to false.

Specified by:
isSchemaNameCaseSensitive in interface SQLFactory

setMaxSchemaNameLength

public void setMaxSchemaNameLength(java.lang.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.

getMaxSchemaNameLength

public java.lang.Integer getMaxSchemaNameLength()
Description copied from interface: SQLFactory

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.

newIdent

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


newSchema

public Schema newSchema(java.lang.String pName)
Description copied from interface: SQLFactory

Creates a new Schema with the given name.

Specified by:
newSchema in interface SQLFactory

newSchema

public Schema newSchema(Schema.Name pName)
Description copied from interface: SQLFactory

Creates a new Schema with the given name.

Specified by:
newSchema in interface SQLFactory

getDefaultSchema

public Schema getDefaultSchema()
Description copied from interface: SQLFactory

Returns the Default schema. The default schema has the name null.

Specified by:
getDefaultSchema in interface SQLFactory

getSchema

public Schema getSchema(java.lang.String pName)
Description copied from interface: SQLFactory

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)
Description copied from interface: SQLFactory

Returns the schema with the given name or null, if no such schema exists.

Specified by:
getSchema in interface SQLFactory

getSchemas

public java.util.Iterator getSchemas()
Description copied from interface: SQLFactory

Returns a list of all schemas. The list includes the default schema, if SQLFactory.getDefaultSchema() was called at any time.

Specified by:
getSchemas in interface SQLFactory

newSelectStatement

public SelectStatement newSelectStatement()
Description copied from interface: SQLFactory

Creates a new SELECT statement.

Specified by:
newSelectStatement in interface SQLFactory

newInsertStatement

public InsertStatement newInsertStatement()
Description copied from interface: SQLFactory

Creates a new INSERT statement.

Specified by:
newInsertStatement in interface SQLFactory

newUpdateStatement

public UpdateStatement newUpdateStatement()
Description copied from interface: SQLFactory

Creates a new UPDATE statement.

Specified by:
newUpdateStatement in interface SQLFactory

newDeleteStatement

public DeleteStatement newDeleteStatement()
Description copied from interface: SQLFactory

Creates a new DELETE statement.

Specified by:
newDeleteStatement in interface SQLFactory

newSchemaImpl

protected Schema newSchemaImpl(Schema.Name pName)

newTableImpl

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

newColumnImpl

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

newSQLGenerator

public SQLGenerator newSQLGenerator()
Description copied from interface: SQLFactory

Creates a new SQLGenerator.

Specified by:
newSQLGenerator in interface SQLFactory

getSchema

public Schema getSchema(java.sql.Connection pConn,
                        java.lang.String pName)
                 throws java.sql.SQLException
Description copied from interface: SQLFactory

Reads the schema named pName from the database.

Specified by:
getSchema in interface SQLFactory
Throws:
java.sql.SQLException

makeSchema

protected Schema makeSchema(Schema.Name pName)

readTables

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

readColumn

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

readTable

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

readPrimaryKey

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

readForeignKeys

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

getSchema

public Schema getSchema(java.sql.Connection pConn,
                        Schema.Name pName)
                 throws java.sql.SQLException
Description copied from interface: SQLFactory

Reads the schema named pName from the database.

Specified by:
getSchema in interface SQLFactory
Throws:
java.sql.SQLException

getTable

public Table getTable(java.sql.Connection pConnection,
                      Schema.Name pSchema,
                      Table.Name pTable)
               throws java.sql.SQLException
Description copied from interface: SQLFactory

Reads the table named pTable from the schema named pSchema in the database.

Specified by:
getTable in interface SQLFactory
Throws:
java.sql.SQLException

getTable

public Table getTable(java.sql.Connection pConnection,
                      java.lang.String pSchema,
                      java.lang.String pTable)
               throws java.sql.SQLException
Description copied from interface: SQLFactory

Reads the table named pTable from the schema named pSchema in the database.

Specified by:
getTable in interface SQLFactory
Throws:
java.sql.SQLException