|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.datatools.modelbase.sql.query.util.SQLQuerySourceFormat
public class SQLQuerySourceFormat
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)
QueryStatement
copyDefaultFormat()
to see how to get a
SQLQuerySourceFormat
with the default settings.
copyFields(SQLQuerySourceFormat)
to see how to copy the values
from another SQLQuerySourceFormat
.
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 |
---|
public static final boolean PRESERVE_SOURCE_FORMAT_DEFAULT
preserveSourceFourmat
setting: false
public static final char STATEMENT_TERMINATOR_DEFAULT
statementTerminator
setting: ';'
public static final char HOSTVARIABLE_PREFIX_DEFAULT
hostVariablePrefix
setting: ':'
public static final char PARAMETER_MARKER_DEFAULT
parameterMarker
setting: '?'
public static final char DELIMITED_IDENTIFIER_QUOTE_DEFAULT
delimitedIdentifierQuote
setting: '"'
public static final java.lang.String OMIT_SCHEMA_DEFAULT
omitSchema
setting: null
public static final int QUALIFY_IDENTIFIERS_IN_CONTEXT
setQualifyIdentifiers(int)
, and
getQualifyIdentifiers()
, used for SQL source generation. Column
and table names will be qualified depending on the context of the SQL
statement.
public static final int QUALIFY_IDENTIFIERS_WITH_SCHEMA_NAMES
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.
public static final int QUALIFY_IDENTIFIERS_WITH_TABLE_NAMES
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!
public static final int QUALIFY_IDENTIFIERS_NEVER
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!
public static final int QUALIFY_IDENTIFIERS_DEFAULT
qualifyIdentifiers
setting: QUALIFY_IDENTIFIERS_IN_CONTEXT
public static final boolean PRESERVE_COMMENTS_DEFAULT
preserveComments
setting: true
public static final boolean GENERATE_COMMENTS_FOR_STATEMENT_DEFAULT
generateCommentsForStatementOnly
setting: true
public static final boolean INSTANCE_IS_FINAL_DEFAULT
instanceIsFinal
setting: false
public static final boolean GENERATE_AS_KEYWORD_FOR_TABLE_CORR_ID_DEFAULT
generateAsKeywordForTableCorrID
setting: true
public static final SQLQuerySourceFormat SQL_SOURCE_FORMAT_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
copyDefaultFormat()
Method Detail |
---|
public static SQLQuerySourceFormat copyDefaultFormat()
SQLQuerySourceFormat
object.
Note: the copy will have the instanceIsfinal
setting set to false.
SQL_SOURCE_FORMAT_DEFAULT
public static SQLQuerySourceFormat copySourceFormat(SQLQuerySourceFormat sourceFormat)
SQLQuerySourceFormat
object.
sourceFormat
- the SQLQuerySourceFormat
to copy
public static void copyFields(SQLQuerySourceFormat source, SQLQuerySourceFormat target)
SQLQuerySourceFormat
donor
to the SQLQuerySourceFormat
recipient
.
source
- the SQLQuerySourceFormat
object containing the fields to copytarget
- the SQLQuerySourceFormat
object to updatepublic void copyFields(SQLQuerySourceFormat sourceFormat)
SQLQuerySourceFormat
to this object.
sourceFormat
- the source SQLQuerySourceFormat
objectpublic char getDelimitedIdentifierQuote()
public void setDelimitedIdentifierQuote(char delimitedIdentifierQuote)
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.
public char getHostVariablePrefix()
public void setHostVariablePrefix(char hostVariablePrefix)
public char getParameterMarker()
public void setParameterMarker(char parameterMarker)
public java.lang.String getOmitSchema()
public void setOmitSchema(java.lang.String omitSchema)
public boolean isPreserveSourceFormat()
public void setPreserveSourceFormat(boolean preserveSourceFormat)
public char getStatementTerminator()
public void setStatementTerminator(char statementTerminator)
public int getQualifyIdentifiers()
QUALIFY_IDENTIFIERS_IN_CONTEXT
.
public void setQualifyIdentifiers(int qualifyIdentifiers)
public boolean getPreserveComments()
public boolean isPreserveComments()
public void setPreserveComments(boolean preserveComments)
public boolean isGenerateCommentsForStatementOnly()
public void setGenerateCommentsForStatementOnly(boolean generateCommentsForStatementOnly)
public boolean getGenerateAsKeywordForTableCorrID()
public void setGenerateAsKeywordForTableCorrID(boolean genAsKeywordForTableCorrID)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |