## 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 lifecycle 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
- `statementTerminator` = the character separating multiple SQL statements
- `hostVariablePrefix` = the character that preceedes a host language variable
- `parameterMarker` = the character that identifies a host language parameter
- `delimitedIdentifierQuote`* = the character that encloses delimited identifiers whose writing in case will be preserved
- `omitSchema` = the current schema (omitted in SQL source, implicit to unqualified table references)
- `qualifyIdentifiers` = the flag describing how identifiers in the SQL source will be qualified
- `preserveComments` = the option to preserve comments in the parsed SQL source or/and the generated SQL source
- `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

* 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 `delimitedIdentifierQuote`: '"'
`static char` `HOSTVARIABLE_PREFIX_DEFAULT` Default value for `hostVariablePrefix`: ':'
`static char` `PARAMETER_MARKER_DEFAULT` Default value for `parameterMarker`: '?'
`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` Note: this `SQLQuerySourceFormat`'s is `final` that means modifications on its members are not allowed.
`static char` `STATEMENT_TERMINATOR_DEFAULT` Default value for `statementTerminator`: ';'

Method Summary
`static SQLQuerySourceFormat` `copyDefaultFormat()`
`void` `copyFields(SQLQuerySourceFormat sourceFormat)` Copies the fields from the given `SQLQuerySourceFormat` `sourceFormat` to this `SQLQuerySourceFormat`.
`static void` `copyFields(SQLQuerySourceFormat donor, SQLQuerySourceFormat recipient)` Copies the fields from the given `SQLQuerySourceFormat` `donor` to the `SQLQuerySourceFormat` `recipient`.
`static SQLQuerySourceFormat` `copySourceFormat(SQLQuerySourceFormat sourceFormat)`
`char` `getDelimitedIdentifierQuote()`
`char` `getHostVariablePrefix()`
`java.lang.String` `getOmitSchema()`
`char` `getParameterMarker()`
`int` `getQualifyIdentifiers()` Returns the policy on how identifiers in the SQL source will be qualified, compare to one of the constants `QUALIFY_IDENTIFIERS_IN_CONTEXT`, , or .
`char` `getStatementTerminator()`
`boolean` `isGenerateCommentsForStatementOnly()` DOCME
`boolean` `isPreserveComments()` DOCME
`boolean` `isPreserveSourceFormat()`
`void` `setDelimitedIdentifierQuote(char delimitedIdentifierQuote)` Note: No modifications of that field allowed, after using this `SQLQuerySourceFormat` as a parameter for a parse! The delimited identifier quote is stored within the identifiers of the `SQLQueryObject`s and further modifications of this `SQLQuerySourceFormat`'s `delimitedIdentifierQuote`, would result into wrong name comparisons.
`void` `setGenerateCommentsForStatementOnly(boolean generateCommentsForStatementOnly)` DOCME
`void` `setHostVariablePrefix(char hostVariablePrefix)`
`void` `setOmitSchema(java.lang.String omitSchema)`
`void` `setParameterMarker(char parameterMarker)`
`void` `setPreserveComments(boolean preserveComments)` DOCME
`void` `setPreserveSourceFormat(boolean preserveSourceFormat)`
`void` `setQualifyIdentifiers(int qualifyIdentifiers)` Sets the policy on how identifiers in the SQL source will be qualified, default is `QUALIFY_IDENTIFIERS_IN_CONTEXT`.
`void` `setStatementTerminator(char statementTerminator)`

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

Field Detail

### STATEMENT_TERMINATOR_DEFAULT

    public static final char STATEMENT_TERMINATOR_DEFAULT

  Default value for `statementTerminator`: ';'

  See Also:
    Constant Field Values

### HOSTVARIABLE_PREFIX_DEFAULT

    public static final char HOSTVARIABLE_PREFIX_DEFAULT

  Default value for `hostVariablePrefix`: ':'

  See Also:
    Constant Field Values

### PARAMETER_MARKER_DEFAULT

    public static final char PARAMETER_MARKER_DEFAULT

  Default value for `parameterMarker`: '?'

  See Also:
    Constant Field Values

### DELIMITED_IDENTIFIER_QUOTE_DEFAULT

    public static final char DELIMITED_IDENTIFIER_QUOTE_DEFAULT

  Default value for `delimitedIdentifierQuote`: '"'

  See Also:
    Constant Field Values

### 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

### SQL_SOURCE_FORMAT_DEFAULT

    public static final SQLQuerySourceFormat SQL_SOURCE_FORMAT_DEFAULT

  Note: this `SQLQuerySourceFormat`'s is `final` that 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()

  Returns:
    a new copy of the `SQL_SOURCE_FORMAT_DEFAULT`

### copySourceFormat

    public static SQLQuerySourceFormat copySourceFormat(SQLQuerySourceFormat sourceFormat)

  Parameters:
    `sourceFormat` - the `SQLQuerySourceFormat` to be copied.
  Returns:
    a new copy of the given `sourceFormat`.

### copyFields

    public static void copyFields(SQLQuerySourceFormat donor,
                                  SQLQuerySourceFormat recipient)

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

  Parameters:
    `donor` - the `SQLQuerySourceFormat` whichs fields to copy
    `recipient` - the `SQLQuerySourceFormat` whichs fields to be overwritten

### copyFields

    public void copyFields(SQLQuerySourceFormat sourceFormat)

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

  Parameters:
    `sourceFormat` - the `SQLQuerySourceFormat` whichs fields to copy

### getDelimitedIdentifierQuote

    public char getDelimitedIdentifierQuote()

  Returns:
    Returns the delimitedIdentifierQuote.

### setDelimitedIdentifierQuote

    public void setDelimitedIdentifierQuote(char delimitedIdentifierQuote)

  Note: No modifications of that field allowed, after using this `SQLQuerySourceFormat` as a parameter for a parse! The delimited identifier quote is stored within the identifiers of the `SQLQueryObject`s and further modifications of this `SQLQuerySourceFormat`'s `delimitedIdentifierQuote`, 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 previously parsed `SQLQueryObject`s reference to this `SQLQuerySourceFormat` and its `delimitedIdentifierQuote` valid.

  Parameters:
    `delimitedIdentifierQuote` - The delimitedIdentifierQuote to set.

### getHostVariablePrefix

    public char getHostVariablePrefix()

  Returns:
    Returns the hostVariablePrefix.

### setHostVariablePrefix

    public void setHostVariablePrefix(char hostVariablePrefix)

  Parameters:
    `hostVariablePrefix` - The hostVariablePrefix to set.

### getParameterMarker

    public char getParameterMarker()

  Returns:
    Returns the parameterMarker.

### setParameterMarker

    public void setParameterMarker(char parameterMarker)

  Parameters:
    `parameterMarker` - The parameterMarker to set.

### getOmitSchema

    public java.lang.String getOmitSchema()

  Returns:
    Returns the omitSchema.

### setOmitSchema

    public void setOmitSchema(java.lang.String omitSchema)

  Parameters:
    `omitSchema` - The omitSchema to set.

### isPreserveSourceFormat

    public boolean isPreserveSourceFormat()

  Returns:
    Returns the preserveSourceFormat.

### setPreserveSourceFormat

    public void setPreserveSourceFormat(boolean preserveSourceFormat)

  Parameters:
    `preserveSourceFormat` - The preserveSourceFormat to set.

### getStatementTerminator

    public char getStatementTerminator()

  Returns:
    Returns the statementTerminator.

### setStatementTerminator

    public void setStatementTerminator(char statementTerminator)

  Parameters:
    `statementTerminator` - The statementTerminator to set.

### getQualifyIdentifiers

    public int getQualifyIdentifiers()

  Returns the policy on how identifiers in the SQL source will be qualified, compare to one of the constants `QUALIFY_IDENTIFIERS_IN_CONTEXT`, , or .

  Returns:
    The constant determining how the identifiers in the SQL source will be qualified, 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, default is `QUALIFY_IDENTIFIERS_IN_CONTEXT`.

  Parameters:
    `qualifyIdentifiers` - The constant determining how the identifiers in the SQL source will be qualified, default is `QUALIFY_IDENTIFIERS_IN_CONTEXT`

### isPreserveComments

    public boolean isPreserveComments()

  DOCME

  Returns:
    Returns the preserveComments.

### setPreserveComments

    public void setPreserveComments(boolean preserveComments)

  DOCME

  Parameters:
    `preserveComments` - The preserveComments to set.

### isGenerateCommentsForStatementOnly

    public boolean isGenerateCommentsForStatementOnly()

  DOCME

  Returns:
    Returns the generateCommentsForStatementOnly.

### setGenerateCommentsForStatementOnly

    public void setGenerateCommentsForStatementOnly(boolean generateCommentsForStatementOnly)

  DOCME

  Parameters:
    `generateCommentsForStatementOnly` - The generateCommentsForStatementOnly to set.

Copyright © 2006 Actuate, IBM Corporation, Sybase, Inc. and others. All rights reserved.