Package com.spotfire.ws.im.ds.sql
Class BasicSQLFilter
- java.lang.Object
-
- com.spotfire.ws.im.ds.sql.BasicSQLFilter
-
-
Constructor Summary
Constructors Constructor Description BasicSQLFilter()
Creates a newBasicSQLFilter
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
formatCatalogName(String name)
Formats a catalog name.String
formatColumn(String column, String tableAlias)
Formats a column expression used in a SELECT, WHERE, GROUP BY or HAVING clause.String
formatColumnAlias(String name)
Formats a column alias to be used in a SELECT clause.String
formatColumnList(String[] columns, String[] types)
Returns SQL for a list column list in a CREATE TABLE statement.String
formatColumnName(String name)
Formats a column name.String
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.String
formatHints(String query, String[] hints)
Formats an SQL query to include hints.String
formatInsertValuesSQL(String table, String[] values)
Return the SQL for inserting a row into a temporary table.String
formatLiteral(String literal, Class type)
String
formatPattern(String pattern, String[] keys, String[] values)
Replaces, in a pattern string, all occurrences of the specified keys with the associated values.String
formatProcedure(String catalog, String schema, String procedure)
Returns the SQL for a procedure expression in a FROM clause.String
formatProcedureName(String name)
String
formatQuery(String query, List preCommands, List postCommands)
Formats an SQL query.String
formatSchemaName(String name)
Formats a schema name.String
formatTable(String catalog, String schema, String table)
Returns the SQL for a table expression in a FROM clause.String
formatTableName(String name)
Formats a table name.String
formatTempTableName(String name)
Formats a temporary table name.JDBCContext
getContext()
Returns theJDBCContext
.String
getSQLAggregateFuntion(String datAggregateFunction)
String
getSQLType(Class c, int length)
Returns the SQL type for a given Java type.void
setContext(JDBCContext c)
Sets theJDBCContext
.
-
-
-
Method Detail
-
setContext
public void setContext(JDBCContext c)
Description copied from interface:SQLFilter
Sets theJDBCContext
.- Specified by:
setContext
in interfaceSQLFilter
- Parameters:
c
- aJDBCContext
instance- Since:
- 3.0
-
getContext
public JDBCContext getContext()
Description copied from interface:SQLFilter
Returns theJDBCContext
.- Specified by:
getContext
in interfaceSQLFilter
- Returns:
- a
JDBCContext
instance - Since:
- 3.0
-
formatCreateTableSQL
public String[] formatCreateTableSQL(String table, String[] columns, String[] types)
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:
SQLFilter.formatColumnList(java.lang.String[], java.lang.String[])
-
formatDropTableSQL
public String[] formatDropTableSQL(String table)
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
public String formatInsertValuesSQL(String table, String[] values)
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
public String formatColumnList(String[] columns, String[] types)
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:
SQLFilter.formatCreateTableSQL(java.lang.String, java.lang.String[], java.lang.String[])
-
getSQLType
public String getSQLType(Class c, int length)
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:
JDBCTypeSettings.getSQLType(java.lang.Class)
-
getSQLAggregateFuntion
public String getSQLAggregateFuntion(String datAggregateFunction)
- 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
public String formatTable(String catalog, String schema, String table)
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:
SQLFilter.formatCatalogName(java.lang.String)
,SQLFilter.formatSchemaName(java.lang.String)
,SQLFilter.formatTableName(java.lang.String)
-
formatProcedure
public String formatProcedure(String catalog, String schema, String procedure)
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:
SQLFilter.formatCatalogName(java.lang.String)
,SQLFilter.formatSchemaName(java.lang.String)
-
formatColumn
public String formatColumn(String column, String tableAlias)
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:
SQLFilter.formatColumnName(java.lang.String)
-
formatColumnName
public String formatColumnName(String name)
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:
JDBCTypeSettings.getColumnNamePattern()
-
formatTableName
public String formatTableName(String name)
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:
JDBCTypeSettings.getTableNamePattern()
-
formatTempTableName
public String formatTempTableName(String name)
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:
JDBCTypeSettings.getTempTableNamePattern()
-
formatSchemaName
public String formatSchemaName(String name)
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:
JDBCTypeSettings.getSchemaNamePattern()
-
formatCatalogName
public String formatCatalogName(String name)
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:
JDBCTypeSettings.getCatalogNamePattern()
-
formatProcedureName
public String formatProcedureName(String name)
- Parameters:
name
- name- Returns:
- procedure name pattern
- Since:
- 3.0
-
formatColumnAlias
public String formatColumnAlias(String name)
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:
JDBCTypeSettings.getColumnAliasPattern()
-
formatLiteral
public String formatLiteral(String literal, Class type)
- 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:
JDBCTypeSettings.getStringLiteralQuote()
-
formatConditionExpression
public String formatConditionExpression(String expr, Class type)
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:
JDBCTypeSettings.getDateFormatExpression()
,JDBCTypeSettings.getTimeFormatExpression()
,JDBCTypeSettings.getDateTimeFormatExpression()
-
formatHints
public String formatHints(String query, String[] hints)
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
public String formatQuery(String query, List preCommands, List postCommands)
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
public String formatPattern(String pattern, String[] keys, String[] values)
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
-
-