Package com.spotfire.ws.im.ds.sql
Class BasicSQLFilter
java.lang.Object
com.spotfire.ws.im.ds.sql.BasicSQLFilter
- All Implemented Interfaces:
SQLFilter
A basic implementation of the SQLFilter
interface.
The SQL formatting is based on specific configuration parameters found in
JDBCTypeSettings
.
- Since:
- 3.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionformatCatalogName
(String name) Formats a catalog name.formatColumn
(String column, String tableAlias) Formats a column expression used in a SELECT, WHERE, GROUP BY or HAVING clause.formatColumnAlias
(String name) Formats a column alias to be used in a SELECT clause.formatColumnList
(String[] columns, String[] types) Returns SQL for a list column list in a CREATE TABLE statement.formatColumnName
(String name) Formats a column name.formatConditionExpression
(String expr, Class type) Formats a condition expression to be used in a WHERE clause.String[]
formatCreateTableSQL
(String table, String[] columns, String[] types) Returns SQL for creating a temporary table.String[]
formatDropTableSQL
(String table) Returns SQL for dropping a temporary table.formatHints
(String query, String[] hints) Formats an SQL query to include hints.formatInsertValuesSQL
(String table, String[] values) Return the SQL for inserting a row into a temporary table.formatLiteral
(String literal, Class type) formatPattern
(String pattern, String[] keys, String[] values) Replaces, in a pattern string, all occurrences of the specified keys with the associated values.formatProcedure
(String catalog, String schema, String procedure) Returns the SQL for a procedure expression in a FROM clause.formatProcedureName
(String name) formatQuery
(String query, List preCommands, List postCommands) Formats an SQL query.formatSchemaName
(String name) Formats a schema name.formatTable
(String catalog, String schema, String table) Returns the SQL for a table expression in a FROM clause.formatTableName
(String name) Formats a table name.formatTempTableName
(String name) Formats a temporary table name.Returns theJDBCContext
.getSQLAggregateFuntion
(String datAggregateFunction) getSQLType
(Class c, int length) Returns the SQL type for a given Java type.void
Sets theJDBCContext
.
-
Constructor Details
-
BasicSQLFilter
public BasicSQLFilter()Creates a newBasicSQLFilter
instance.- Since:
- 3.0
-
-
Method Details
-
setContext
Description copied from interface:SQLFilter
Sets theJDBCContext
.- Specified by:
setContext
in interfaceSQLFilter
- Parameters:
c
- aJDBCContext
instance- Since:
- 3.0
-
getContext
Description copied from interface:SQLFilter
Returns theJDBCContext
.- Specified by:
getContext
in interfaceSQLFilter
- Returns:
- a
JDBCContext
instance - Since:
- 3.0
-
formatCreateTableSQL
Description copied from interface:SQLFilter
Returns SQL for creating a temporary table.- Specified by:
formatCreateTableSQL
in interfaceSQLFilter
- Parameters:
table
- a table namecolumns
- a list of column namestypes
- a list of column types- Returns:
- a list of SQL commands
- Since:
- 3.0
- See Also:
-
formatDropTableSQL
Description copied from interface:SQLFilter
Returns SQL for dropping a temporary table.- Specified by:
formatDropTableSQL
in interfaceSQLFilter
- Parameters:
table
- a table name- Returns:
- a list of SQL commands
- Since:
- 3.0
-
formatInsertValuesSQL
Description copied from interface:SQLFilter
Return the SQL for inserting a row into a temporary table.- Specified by:
formatInsertValuesSQL
in interfaceSQLFilter
- Parameters:
table
- a table namevalues
- a list of values, may be?
for a prepared statement- Returns:
- an SQL command
- Since:
- 3.0
-
formatColumnList
Description copied from interface:SQLFilter
Returns SQL for a list column list in a CREATE TABLE statement.- Specified by:
formatColumnList
in interfaceSQLFilter
- Parameters:
columns
- a list of column namestypes
- a list of column types- Returns:
- an SQL column list
- Since:
- 3.0
- See Also:
-
getSQLType
Description copied from interface:SQLFilter
Returns the SQL type for a given Java type.- Specified by:
getSQLType
in interfaceSQLFilter
- Parameters:
c
- a Java typelength
- the length whentype
isString
- Returns:
- an SQL type
- Since:
- 3.0
- See Also:
-
getSQLAggregateFuntion
- Specified by:
getSQLAggregateFuntion
in interfaceSQLFilter
- Parameters:
datAggregateFunction
- datAggregateFunction- Returns:
- Returns the SQL aggregate function that maps to the given DAT aggregate function, or null if no mapping exists.
- Since:
- 3.0
-
formatTable
Description copied from interface:SQLFilter
Returns the SQL for a table expression in a FROM clause.- Specified by:
formatTable
in interfaceSQLFilter
- Parameters:
catalog
- a catalog name, may benull
schema
- a schema name, may benull
table
- a table name- Returns:
- an SQL table expression
- Since:
- 3.0
- See Also:
-
formatProcedure
Description copied from interface:SQLFilter
Returns the SQL for a procedure expression in a FROM clause.- Specified by:
formatProcedure
in interfaceSQLFilter
- Parameters:
catalog
- a catalog name, may benull
schema
- a schema name, may benull
procedure
- a procedure name- Returns:
- an SQL procedure expression
- Since:
- 3.0
- See Also:
-
formatColumn
Description copied from interface:SQLFilter
Formats a column expression used in a SELECT, WHERE, GROUP BY or HAVING clause.- Specified by:
formatColumn
in interfaceSQLFilter
- Parameters:
column
- a column nametableAlias
- a table alias- Returns:
- an SQL column expression
- Since:
- 3.0
- See Also:
-
formatColumnName
Description copied from interface:SQLFilter
Formats a column name.- Specified by:
formatColumnName
in interfaceSQLFilter
- Parameters:
name
- a column name- Returns:
- an SQL column name
- Since:
- 3.0
- See Also:
-
formatTableName
Description copied from interface:SQLFilter
Formats a table name.- Specified by:
formatTableName
in interfaceSQLFilter
- Parameters:
name
- a table name- Returns:
- an SQL table name
- Since:
- 3.0
- See Also:
-
formatTempTableName
Description copied from interface:SQLFilter
Formats a temporary table name.- Specified by:
formatTempTableName
in interfaceSQLFilter
- Parameters:
name
- a table name- Returns:
- an SQL table name
- Since:
- 3.0
- See Also:
-
formatSchemaName
Description copied from interface:SQLFilter
Formats a schema name.- Specified by:
formatSchemaName
in interfaceSQLFilter
- Parameters:
name
- a schema name- Returns:
- an SQL schema name
- Since:
- 3.0
- See Also:
-
formatCatalogName
Description copied from interface:SQLFilter
Formats a catalog name.- Specified by:
formatCatalogName
in interfaceSQLFilter
- Parameters:
name
- a catalog name- Returns:
- an SQL catalog name
- Since:
- 3.0
- See Also:
-
formatProcedureName
- Parameters:
name
- name- Returns:
- procedure name pattern
- Since:
- 3.0
-
formatColumnAlias
Description copied from interface:SQLFilter
Formats a column alias to be used in a SELECT clause.- Specified by:
formatColumnAlias
in interfaceSQLFilter
- Parameters:
name
- a column alias- Returns:
- an SQL column alias
- Since:
- 3.0
- See Also:
-
formatLiteral
- Specified by:
formatLiteral
in interfaceSQLFilter
- Parameters:
literal
- a literal expressiontype
- a column type- Returns:
- Formats a literal to be used in a WHERE clause.
- Since:
- 3.0
- See Also:
-
formatConditionExpression
Description copied from interface:SQLFilter
Formats a condition expression to be used in a WHERE clause.- Specified by:
formatConditionExpression
in interfaceSQLFilter
- Parameters:
expr
- a condition expressiontype
- a column type- Returns:
- an SQL condition expression
- Since:
- 3.0
- See Also:
-
formatHints
Description copied from interface:SQLFilter
Formats an SQL query to include hints.- Specified by:
formatHints
in interfaceSQLFilter
- Parameters:
query
- an SQL queryhints
- a list of hints- Returns:
- an SQL query
- Since:
- 3.0
-
formatQuery
Description copied from interface:SQLFilter
Formats an SQL query. This method is called as a the last step when building an SQL query.- Specified by:
formatQuery
in interfaceSQLFilter
- Parameters:
query
- an SQL querypreCommands
- add to this list any commands to be executed before the querypostCommands
- add to this list any commands to be executed after the query- Returns:
- an SQL query
- Since:
- 3.0
-
formatPattern
Replaces, in a pattern string, all occurrences of the specified keys with the associated values.- Parameters:
pattern
- the string in which to do the substitutionkeys
- a list of keys to substitutevalues
- a list of values- Returns:
- the pattern with keys substituted with values
- Since:
- 3.0
-