org.eigenbase.sql
Class SqlDialect

java.lang.Object
  extended by org.eigenbase.sql.SqlDialect

public class SqlDialect
extends Object

SqlDialect encapsulates the differences between dialects of SQL, for the benefit of a SqlWriter.


Field Summary
(package private)  String databaseProductName
           
(package private)  String identifierQuoteString
           
 
Constructor Summary
SqlDialect(DatabaseMetaData databaseMetaData)
          Creates a SqlDialect
 
Method Summary
protected  boolean allowsAs()
           
 boolean identifierNeedsToBeQuoted(String val)
          Returns whether a given identifier needs to be quoted.
 boolean isAccess()
           
 boolean isOracle()
           
 boolean isPostgres()
           
 boolean isSqlServer()
           
 String quoteIdentifier(String val)
          Encloses an identifier in quotation marks appropriate for the current SQL dialect.
 StringBuilder quoteIdentifier(StringBuilder buf, List<String> identifiers)
          Quotes a multi-part identifier.
 StringBuilder quoteIdentifier(StringBuilder buf, String val)
          Encloses an identifier in quotation marks appropriate for the current SQL dialect, writing the result to a StringBuilder.
 String quoteStringLiteral(String val)
          Converts a string into a string literal.
protected  boolean requiresAliasForFromItems()
           
 String unquoteStringLiteral(String val)
          Converts a string literal back into a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

databaseProductName

String databaseProductName

identifierQuoteString

String identifierQuoteString
Constructor Detail

SqlDialect

public SqlDialect(DatabaseMetaData databaseMetaData)
Creates a SqlDialect

Parameters:
databaseMetaData - used to determine which dialect of SQL to generate
Method Detail

isAccess

public boolean isAccess()

isOracle

public boolean isOracle()

isPostgres

public boolean isPostgres()

isSqlServer

public boolean isSqlServer()

quoteIdentifier

public String quoteIdentifier(String val)
Encloses an identifier in quotation marks appropriate for the current SQL dialect.

For example, quoteIdentifier("emp") yields a string containing "emp" in Oracle, and a string containing [emp] in Access.

Parameters:
val - Identifier to quote
Returns:
Quoted identifier

quoteIdentifier

public StringBuilder quoteIdentifier(StringBuilder buf,
                                     String val)
Encloses an identifier in quotation marks appropriate for the current SQL dialect, writing the result to a StringBuilder.

For example, quoteIdentifier("emp") yields a string containing "emp" in Oracle, and a string containing [emp] in Access.

Parameters:
buf - Buffer
val - Identifier to quote
Returns:
The buffer

quoteIdentifier

public StringBuilder quoteIdentifier(StringBuilder buf,
                                     List<String> identifiers)
Quotes a multi-part identifier.

Parameters:
buf - Buffer
identifiers - List of parts of the identifier to quote
Returns:
The buffer

identifierNeedsToBeQuoted

public boolean identifierNeedsToBeQuoted(String val)
Returns whether a given identifier needs to be quoted.


quoteStringLiteral

public String quoteStringLiteral(String val)
Converts a string into a string literal. For example, can't run becomes 'can''t run'.


unquoteStringLiteral

public String unquoteStringLiteral(String val)
Converts a string literal back into a string. For example, 'can''t run' becomes can't run.


allowsAs

protected boolean allowsAs()

requiresAliasForFromItems

protected boolean requiresAliasForFromItems()