## org.eclipse.datatools.modelbase.sql.query.util
Class SQLQuerySourceFormat

    java.lang.Object
      org.eclipse.datatools.modelbase.sql.query.util.SQLQuerySourceFormat

    public class SQLQuerySourceFormat

extends java.lang.Object

The `SQLQuerySourceFormat` can be used to provide settings regarding the SQL source text for parsing or source generation from a `SQLQueryObject` model representation. The SQLQuerySourceFormat will be maintained during the life cycle of a `QueryStatement` instance (via reference to SQLQuerySourceInfo, see `SQLQueryObject.getSourceInfo()`, `SQLQuerySourceInfo.getSqlFormat()`), where all `SQLQueryObject` elements of one `QueryStatement` share one instance of a `SQLQuerySourceFormat`. That way the settings you specify for the parse are still available for generating the SQL source text for a `QueryStatement`. Most source format options can be modified during the life cycle of a `QueryStatement`, exceptions are marked with a * below.

Source format options:

- `preserveSourceFormat` = the option to preserve the input source formating when SQL source text is generated (default: false)
- `statementTerminator` = the character separating multiple SQL statements (default: '')
- `hostVariablePrefix` = the character that precedes a host language variable (default: ':')
- `parameterMarker` = the character that identifies a host language parameter (default: '?')
- `delimitedIdentifierQuote`* = the character that encloses delimited identifiers whose writing in case will be preserved (default: '"')
- `omitSchema` = the current schema (omitted in SQL source, implicit to unqualified table references) (default: null)
- `qualifyIdentifiers` = the flag describing how identifiers in the SQL source will be qualified. See the QUALIFY_IDENTIFIER_xxx constants defined in this class (default: qualify identifiers in context)
- `preserveComments` = the option to preserve comments in the parsed SQL source or/and the generated SQL source (default: true)
- `generateCommentsForStatementOnly` = the option to generate comments for the SQL source only in the context of the complete statement, or if set to `false`, for single SQL Query objects outside the context of a statement as well (default: true)
- `instanceIsFinal` = indicates whether or not the instance can be modified (default: false)
- `generateAsKeywordForTableCorrID` = option to include (or not) the AS keyword when generating SQL for a table correlation ID. (The AS is optional for DB2. Oracle does not allow it at all.) (default: true)

* Source format options that can not be modified during the life cycle of a `QueryStatement`
See `copyDefaultFormat()` to see how to get a `SQLQuerySourceFormat` with the default settings.
See `copyFields(SQLQuerySourceFormat)` to see how to copy the values from another `SQLQuerySourceFormat`.

Author:
  ckadner

Field Summary
`static char` `DELIMITED_IDENTIFIER_QUOTE_DEFAULT` Default value for the `delimitedIdentifierQuote` setting: '"'
`static boolean` `GENERATE_AS_KEYWORD_FOR_TABLE_CORR_ID_DEFAULT` Default value for the `generateAsKeywordForTableCorrID` setting: `true`
`static boolean` `GENERATE_COMMENTS_FOR_STATEMENT_DEFAULT` Default value for the `generateCommentsForStatementOnly` setting: `true`
`static char` `HOSTVARIABLE_PREFIX_DEFAULT` Default value for the `hostVariablePrefix` setting: ':'
`static boolean` `INSTANCE_IS_FINAL_DEFAULT` Default value for the `instanceIsFinal` setting: `false`
`static java.lang.String` `OMIT_SCHEMA_DEFAULT` Default value for `omitSchema` setting: `null`
`static char` `PARAMETER_MARKER_DEFAULT` Default value for the `parameterMarker` setting: '?'
`static boolean` `PRESERVE_COMMENTS_DEFAULT` Default value for the `preserveComments` setting: `true`
`static boolean` `PRESERVE_SOURCE_FORMAT_DEFAULT` Default value for `preserveSourceFourmat` setting: `false`
`static int` `QUALIFY_IDENTIFIERS_DEFAULT` Default value for the `qualifyIdentifiers` setting: `QUALIFY_IDENTIFIERS_IN_CONTEXT`
`static int` `QUALIFY_IDENTIFIERS_IN_CONTEXT` Default constant for `setQualifyIdentifiers(int)`, and `getQualifyIdentifiers()`, used for SQL source generation.
`static int` `QUALIFY_IDENTIFIERS_NEVER` Constant for `setQualifyIdentifiers(int)`, and `getQualifyIdentifiers()`, used for SQL source generation.
`static int` `QUALIFY_IDENTIFIERS_WITH_SCHEMA_NAMES` Constant for `setQualifyIdentifiers(int)`, and `getQualifyIdentifiers()`, used for SQL source generation.
`static int` `QUALIFY_IDENTIFIERS_WITH_TABLE_NAMES` Constant for `setQualifyIdentifiers(int)`, and `getQualifyIdentifiers()`, used for SQL source generation.
`static SQLQuerySourceFormat` `SQL_SOURCE_FORMAT_DEFAULT` Define the default `SQLQuerySourceFormat` object.
`static char` `STATEMENT_TERMINATOR_DEFAULT` Default value for the `statementTerminator` setting: ';'

Method Summary
`static SQLQuerySourceFormat` `copyDefaultFormat()` Creates and returns a copy of the default `SQLQuerySourceFormat` object.
`void` `copyFields(SQLQuerySourceFormat sourceFormat)` Copies the fields from the given `SQLQuerySourceFormat` to this object.
`static void` `copyFields(SQLQuerySourceFormat source, SQLQuerySourceFormat target)` Copies the fields from the given `SQLQuerySourceFormat` `donor` to the `SQLQuerySourceFormat` `recipient`.
`static SQLQuerySourceFormat` `copySourceFormat(SQLQuerySourceFormat sourceFormat)` Creates and returns a copy of the given `SQLQuerySourceFormat` object.
`char` `getDelimitedIdentifierQuote()` Gets the delimited identifier quote character to use for parsing and code generation.
`boolean` `getGenerateAsKeywordForTableCorrID()` Gets whether or not to include the AS keyword when generating SQL for a table correlation ID.
`char` `getHostVariablePrefix()` Gets the host variable prefix character to use.
`java.lang.String` `getOmitSchema()` Gets the omit schema name to use.
`char` `getParameterMarker()` Gets the parameter marker character to use.
`boolean` `getPreserveComments()` Gets whether or not to preserve comments in the generated SQL.
`int` `getQualifyIdentifiers()` Gets the policy setting on how identifiers in the SQL source will be qualified.
`char` `getStatementTerminator()` Gets the statement terminator character to use.
`boolean` `isGenerateCommentsForStatementOnly()` Gets whether or not to generate comments in the context of a complete statement only.
`boolean` `isPreserveComments()` Gets whether or not to preserve comments in the generated SQL is set true.
`boolean` `isPreserveSourceFormat()` Gets the preserve source format setting.
`void` `setDelimitedIdentifierQuote(char delimitedIdentifierQuote)` Sets the delimited identifier quote character to use for parsing and code generation.
`void` `setGenerateAsKeywordForTableCorrID(boolean genAsKeywordForTableCorrID)` Sets whether or not to include the AS keyword when generating SQL for a table correlation ID.
`void` `setGenerateCommentsForStatementOnly(boolean generateCommentsForStatementOnly)` Sets whether or not to generate comments in the context of a complete statement only.
`void` `setHostVariablePrefix(char hostVariablePrefix)` Sets the host variable prefix character to use to the given character.
`void` `setOmitSchema(java.lang.String omitSchema)` Sets the omit schema name to use.
`void` `setParameterMarker(char parameterMarker)` Sets the parameter marker character to use to the given character.
`void` `setPreserveComments(boolean preserveComments)` Sets whether or not to preserve comments in the generated SQL.
`void` `setPreserveSourceFormat(boolean preserveSourceFormat)` Sets the preserve source format setting to the given value.
`void` `setQualifyIdentifiers(int qualifyIdentifiers)` Sets the policy on how identifiers in the SQL source will be qualified.
`void` `setStatementTerminator(char statementTerminator)` Sets the statement terminator character to use to the given character.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### PRESERVE_SOURCE_FORMAT_DEFAULT

    public static final boolean PRESERVE_SOURCE_FORMAT_DEFAULT

  Default value for `preserveSourceFourmat` setting: `false`

  See Also:
    Constant Field Values

### STATEMENT_TERMINATOR_DEFAULT

    public static final char STATEMENT_TERMINATOR_DEFAULT

  Default value for the `statementTerminator` setting: ';'

  See Also:
    Constant Field Values

### HOSTVARIABLE_PREFIX_DEFAULT

    public static final char HOSTVARIABLE_PREFIX_DEFAULT

  Default value for the `hostVariablePrefix` setting: ':'

  See Also:
    Constant Field Values

### PARAMETER_MARKER_DEFAULT

    public static final char PARAMETER_MARKER_DEFAULT

  Default value for the `parameterMarker` setting: '?'

  See Also:
    Constant Field Values

### DELIMITED_IDENTIFIER_QUOTE_DEFAULT

    public static final char DELIMITED_IDENTIFIER_QUOTE_DEFAULT

  Default value for the `delimitedIdentifierQuote` setting: '"'

  See Also:
    Constant Field Values

### OMIT_SCHEMA_DEFAULT

    public static final java.lang.String OMIT_SCHEMA_DEFAULT

  Default value for `omitSchema` setting: `null`

### QUALIFY_IDENTIFIERS_IN_CONTEXT

    public static final int QUALIFY_IDENTIFIERS_IN_CONTEXT

  Default constant for `setQualifyIdentifiers(int)`, and `getQualifyIdentifiers()`, used for SQL source generation. Column and table names will be qualified depending on the context of the SQL statement.

  See Also:
    Constant Field Values

### QUALIFY_IDENTIFIERS_WITH_SCHEMA_NAMES

    public static final int QUALIFY_IDENTIFIERS_WITH_SCHEMA_NAMES

  Constant for `setQualifyIdentifiers(int)`, and `getQualifyIdentifiers()`, used for SQL source generation. Table names will always be qualified with schema names and column names with table and schema names.

  See Also:
    Constant Field Values

### QUALIFY_IDENTIFIERS_WITH_TABLE_NAMES

    public static final int QUALIFY_IDENTIFIERS_WITH_TABLE_NAMES

  Constant for `setQualifyIdentifiers(int)`, and `getQualifyIdentifiers()`, used for SQL source generation. Table names will never be qualified with schema names and column names will only be qualified with table names.

  Note: this configuration can lead to incorrectly generated source for SQL statements!

  See Also:
    Constant Field Values

### QUALIFY_IDENTIFIERS_NEVER

    public static final int QUALIFY_IDENTIFIERS_NEVER

  Constant for `setQualifyIdentifiers(int)`, and `getQualifyIdentifiers()`, used for SQL source generation. Table names will never be qualified with schema names and column names will only be qualified with table names.

  Note: this configuration can lead to incorrectly generated source for SQL statements!

  See Also:
    Constant Field Values

### QUALIFY_IDENTIFIERS_DEFAULT

    public static final int QUALIFY_IDENTIFIERS_DEFAULT

  Default value for the `qualifyIdentifiers` setting: `QUALIFY_IDENTIFIERS_IN_CONTEXT`

  See Also:
    Constant Field Values

### PRESERVE_COMMENTS_DEFAULT

    public static final boolean PRESERVE_COMMENTS_DEFAULT

  Default value for the `preserveComments` setting: `true`

  See Also:
    Constant Field Values

### GENERATE_COMMENTS_FOR_STATEMENT_DEFAULT

    public static final boolean GENERATE_COMMENTS_FOR_STATEMENT_DEFAULT

  Default value for the `generateCommentsForStatementOnly` setting: `true`

  See Also:
    Constant Field Values

### INSTANCE_IS_FINAL_DEFAULT

    public static final boolean INSTANCE_IS_FINAL_DEFAULT

  Default value for the `instanceIsFinal` setting: `false`

  See Also:
    Constant Field Values

### GENERATE_AS_KEYWORD_FOR_TABLE_CORR_ID_DEFAULT

    public static final boolean GENERATE_AS_KEYWORD_FOR_TABLE_CORR_ID_DEFAULT

  Default value for the `generateAsKeywordForTableCorrID` setting: `true`

  See Also:
    Constant Field Values

### SQL_SOURCE_FORMAT_DEFAULT

    public static final SQLQuerySourceFormat SQL_SOURCE_FORMAT_DEFAULT

  Define the default `SQLQuerySourceFormat` object. Note: this `SQLQuerySourceFormat`'s `instanceIsFinal` setting means modifications on its members are not allowed. Every attempt to do so will raise an `UnsupportedOperationException`. Use ``copyDefaultFormat()`` to get a copy of ``SQL_SOURCE_FORMAT_DEFAULT`` Default `SQLQuerySourceFormat` properties:
  - `preserveSourceFormat` = `false`
  - `statementTerminator` = `STATEMENT_TERMINATOR_DEFAULT`
  - `hostVariablePrefix` = `HOSTVARIABLE_PREFIX_DEFAULT`
  - `parameterMarker` = `PARAMETER_MARKER_DEFAULT`
  - `delimitedIdentifierQuote` = `DELIMITED_IDENTIFIER_QUOTE_DEFAULT`
  - `omitSchema` = `null`;
  - `qualifyIdentifiers` = `QUALIFY_IDENTIFIERS_IN_CONTEXT`
  - `preserveComments` = `true`
  - `generateCommentsForStatementOnly` = `true`

  See Also:
    `copyDefaultFormat()`

Method Detail

### copyDefaultFormat

    public static SQLQuerySourceFormat copyDefaultFormat()

  Creates and returns a copy of the default `SQLQuerySourceFormat` object. Note: the copy will have the `instanceIsfinal` setting set to false.

  Returns:
    a new copy of the `SQL_SOURCE_FORMAT_DEFAULT`

### copySourceFormat

    public static SQLQuerySourceFormat copySourceFormat(SQLQuerySourceFormat sourceFormat)

  Creates and returns a copy of the given `SQLQuerySourceFormat` object.

  Parameters:
    `sourceFormat` - the `SQLQuerySourceFormat` to copy
  Returns:
    the copy

### copyFields

    public static void copyFields(SQLQuerySourceFormat source,
                                  SQLQuerySourceFormat target)

  Copies the fields from the given `SQLQuerySourceFormat` `donor` to the `SQLQuerySourceFormat` `recipient`.

  Parameters:
    `source` - the `SQLQuerySourceFormat` object containing the fields to copy
    `target` - the `SQLQuerySourceFormat` object to update

### copyFields

    public void copyFields(SQLQuerySourceFormat sourceFormat)

  Copies the fields from the given `SQLQuerySourceFormat` to this object.

  Parameters:
    `sourceFormat` - the source `SQLQuerySourceFormat` object

### getDelimitedIdentifierQuote

    public char getDelimitedIdentifierQuote()

  Gets the delimited identifier quote character to use for parsing and code generation.

### setDelimitedIdentifierQuote

    public void setDelimitedIdentifierQuote(char delimitedIdentifierQuote)

  Sets the delimited identifier quote character to use for parsing and code generation. Note: No modifications of of this setting are allowed after using this `SQLQuerySourceFormat` as a parameter for a parse! The delimited identifier quote character is stored within the identifiers of the `SQLQueryObject`s and further modifications to this setting would result into wrong name comparisons. If you need to modify it, make a copy of the current `SQLQuerySourceFormat` by using `copySourceFormat(SQLQuerySourceFormat)` to keep the previously parsed `SQLQueryObject`s references to this `SQLQuerySourceFormat` and its `delimitedIdentifierQuote` valid.

### getHostVariablePrefix

    public char getHostVariablePrefix()

  Gets the host variable prefix character to use.

### setHostVariablePrefix

    public void setHostVariablePrefix(char hostVariablePrefix)

  Sets the host variable prefix character to use to the given character.

### getParameterMarker

    public char getParameterMarker()

  Gets the parameter marker character to use.

### setParameterMarker

    public void setParameterMarker(char parameterMarker)

  Sets the parameter marker character to use to the given character.

### getOmitSchema

    public java.lang.String getOmitSchema()

  Gets the omit schema name to use. If non-null, this schema name is omitted from generated SQL.

### setOmitSchema

    public void setOmitSchema(java.lang.String omitSchema)

  Sets the omit schema name to use. If non-null, this schema name is omitted from generated SQL.

### isPreserveSourceFormat

    public boolean isPreserveSourceFormat()

  Gets the preserve source format setting.

### setPreserveSourceFormat

    public void setPreserveSourceFormat(boolean preserveSourceFormat)

  Sets the preserve source format setting to the given value.

### getStatementTerminator

    public char getStatementTerminator()

  Gets the statement terminator character to use.

### setStatementTerminator

    public void setStatementTerminator(char statementTerminator)

  Sets the statement terminator character to use to the given character.

### getQualifyIdentifiers

    public int getQualifyIdentifiers()

  Gets the policy setting on how identifiers in the SQL source will be qualified. See the <cod>QUALIFY_IDENTIFIER_xxx constants defined in this class. The default is `QUALIFY_IDENTIFIERS_IN_CONTEXT`.

### setQualifyIdentifiers

    public void setQualifyIdentifiers(int qualifyIdentifiers)

  Sets the policy on how identifiers in the SQL source will be qualified.

### getPreserveComments

    public boolean getPreserveComments()

  Gets whether or not to preserve comments in the generated SQL.

### isPreserveComments

    public boolean isPreserveComments()

  Gets whether or not to preserve comments in the generated SQL is set true.

### setPreserveComments

    public void setPreserveComments(boolean preserveComments)

  Sets whether or not to preserve comments in the generated SQL.

### isGenerateCommentsForStatementOnly

    public boolean isGenerateCommentsForStatementOnly()

  Gets whether or not to generate comments in the context of a complete statement only. When false, comments will be generated in the SQL objects outside the context of a complete statement.

### setGenerateCommentsForStatementOnly

    public void setGenerateCommentsForStatementOnly(boolean generateCommentsForStatementOnly)

  Sets whether or not to generate comments in the context of a complete statement only. When false, comments will be generated in the SQL objects outside the context of a complete statement.

### getGenerateAsKeywordForTableCorrID

    public boolean getGenerateAsKeywordForTableCorrID()

  Gets whether or not to include the AS keyword when generating SQL for a table correlation ID.

### setGenerateAsKeywordForTableCorrID

    public void setGenerateAsKeywordForTableCorrID(boolean genAsKeywordForTableCorrID)

  Sets whether or not to include the AS keyword when generating SQL for a table correlation ID.