org.eclipse.datatools.sqltools.parsers.sql.query.postparse
Class DataTypeResolver

java.lang.Object
  extended by org.eclipse.datatools.sqltools.parsers.sql.query.postparse.DataTypeResolver
All Implemented Interfaces:
PostParseProcessor

public class DataTypeResolver
extends java.lang.Object
implements PostParseProcessor

The DataTypeResolver resolves the DataTypes of QueryValueExpressions based on the DataTypes already been resolved for the ValueExpressionColumns. Note: the QueryStatement has to be processed by the TableReferenceResolver before.

Author:
ckadner@us.ibm.com

Field Summary
static java.lang.String ERROR_CODE_DATATYPE_UNRESOLVED
          Error code constant - not a message, data type unresolved
static java.lang.String ERROR_CODE_DATATYPES_INCOMPATIBLE
          Error code constant - not a message, incompatible data types
static java.lang.String ERROR_CODE_VARIABLE_TYPE_UNCLEAR
          Error code constant - not a message, host variable/parameter data type unresolved
 
Constructor Summary
DataTypeResolver()
          Constructs a new DataTypeResolver.
DataTypeResolver(boolean logError)
          Constructs a new DataTypeResolver.
 
Method Summary
 void config(PostParseProcessorConfiguration config)
          Configures this PostParseProcessor with the arguments provided in the given PostParseProcessorConfiguration.
 java.util.Map getParsedObjectsReplacementMap()
          Returns a Map containing parsed SQLQueryObjects mapped to either the SQLQueryObject that replaces it, or is mapped to null, if that parsed object simply is to be removed.
 java.lang.Class[] getProcessCandidateTypes()
          This DatTypeResolver's candidate types are: QueryStatement ValueExpression
 java.util.List process(SQLQueryObject sqlQuery)
          The call back method invoked for each of the SQLQueryObjects in the SQLQueryObject model instance returned by the parser, if the SQLQueryObject complies with one of the types in the Class[] returned by this PostParseProcessor.getProcessCandidateTypes()
 void resetState()
          If this PostParseProcessor is stateful within the context of one QueryStatement, this method should reset the state, as it might be used for post parse processing of more than one QueryStatement.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR_CODE_DATATYPE_UNRESOLVED

public static final java.lang.String ERROR_CODE_DATATYPE_UNRESOLVED
Error code constant - not a message, data type unresolved

See Also:
Constant Field Values

ERROR_CODE_VARIABLE_TYPE_UNCLEAR

public static final java.lang.String ERROR_CODE_VARIABLE_TYPE_UNCLEAR
Error code constant - not a message, host variable/parameter data type unresolved

See Also:
Constant Field Values

ERROR_CODE_DATATYPES_INCOMPATIBLE

public static final java.lang.String ERROR_CODE_DATATYPES_INCOMPATIBLE
Error code constant - not a message, incompatible data types

See Also:
Constant Field Values
Constructor Detail

DataTypeResolver

public DataTypeResolver()
Constructs a new DataTypeResolver.


DataTypeResolver

public DataTypeResolver(boolean logError)
Constructs a new DataTypeResolver.

Parameters:
logError - if true errors will be logged to the console, default is true
Method Detail

getProcessCandidateTypes

public java.lang.Class[] getProcessCandidateTypes()
This DatTypeResolver's candidate types are:

Specified by:
getProcessCandidateTypes in interface PostParseProcessor
Returns:
Class[] of SQLObject types
See Also:
org.eclipse.datatools.sqltools.parsers.sql.query.postparse.PostParseProcessor#getProcessCandidateTypes()

config

public void config(PostParseProcessorConfiguration config)
Description copied from interface: PostParseProcessor
Configures this PostParseProcessor with the arguments provided in the given PostParseProcessorConfiguration.

Specified by:
config in interface PostParseProcessor
Parameters:
config - the configuration arguments that can be consumed by this PostParseProcessor

process

public java.util.List process(SQLQueryObject sqlQuery)
                       throws SQLParserException
Description copied from interface: PostParseProcessor
The call back method invoked for each of the SQLQueryObjects in the SQLQueryObject model instance returned by the parser, if the SQLQueryObject complies with one of the types in the Class[] returned by this PostParseProcessor.getProcessCandidateTypes()

Specified by:
process in interface PostParseProcessor
Parameters:
sqlQuery - instance of one of the types in the Class[] returned by PostParseProcessor.getProcessCandidateTypes()
Returns:
List of SQLParseErrorInfo objects, with information about the error encountered, must not be null
Throws:
SQLParserException - if the error encountered is severe enough to discard the instance of the SQLQueryObject model returned by the parser

resetState

public void resetState()
Description copied from interface: PostParseProcessor
If this PostParseProcessor is stateful within the context of one QueryStatement, this method should reset the state, as it might be used for post parse processing of more than one QueryStatement. This method is invoked after the SQLParserManager bottom-up processed the SQLQueryObject elements of a QueryStatement up to the top/root-element - the QueryStatement object itself.

Specified by:
resetState in interface PostParseProcessor
See Also:
org.eclipse.datatools.sqltools.parsers.sql.query.postparse.PostParseProcessor#resetState()

getParsedObjectsReplacementMap

public java.util.Map getParsedObjectsReplacementMap()
Description copied from interface: PostParseProcessor
Returns a Map containing parsed SQLQueryObjects mapped to either the SQLQueryObject that replaces it, or is mapped to null, if that parsed object simply is to be removed. This method will be invoked after this PostParseProcessor is done processing one QueryStatement before the PostParseProcessor.resetState() method is called. This method should return a mapping, if during the post parse processing SQLQueryObjects are found that are determined to have been created by the parser mistakenly, because the parser did not have the knowledge about context or semantics. This then PostParseProcessor might create a substitution for it or simply delete it by mapping the original SQLQueryObject to null. By providing this mapping, invalid SQLQueryObjects can be removed from the parser's parsed-element-list and therefore will not be subject to further post parse processing of other PostParseProcessors.

Specified by:
getParsedObjectsReplacementMap in interface PostParseProcessor
Returns:
Map containing parsed SQLQueryObjects mapped to either the SQLQueryObject that replaces it to null, if that parsed object simply is to be removed