## org.eclipse.datatools.sqltools.parsers.sql.postparse
Interface PostParseProcessor

All Known Implementing Classes:
  DataTypeResolver, RoutineReferenceResolver, TableReferenceResolver

    public interface PostParseProcessor

Author:
  ckadner A `PostParseProcessor` can be invoked by the `SQLParserManager` as part of the semantical resolving and validation phase after the syntactical phase, the actual parse itself. After the successful parse the `SQLParserManager` will bottom-up process the created a `SQLQueryObject` model instance and for each contained `SQLQueryObject` will check for a given `PostParseProcessor`, to be invoked by `process(SQLQueryObject)`, if the `SQLQueryObject` is a subtype of one of the `PostParseProcessor`'s candidate types (`getProcessCandidateTypes()`). Stateful `PostParseProcessor`s can collect information that are valid within the context of one `QueryStatement`. If a `PostParseProcessor` is stateful, its state can be reset after each processed `QueryStatement` by implementing `resetState()` which will be called after the `QueryStatement` processing is completed. A `PostParseProcessor` can also do modifications on the `SQLObject` stack of the parser, for example to invalidate `SQLObject`s for further post parse processing or replacing a `SQLObject` that was generated by the parser with a `SQLObject` generated in exchange by the `PostParseProcessor`. The `SQLObject` replacement mapping will be retrieved with `getParsedObjectsReplacementMap()` before the `resetState()` is called.

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 `SQLQueryObject`s 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()` The candidate types for this `PostParseProcessor`.
`java.util.List` `process(SQLQueryObject sqlQuery)` The call back method invoked for each of the `SQLQueryObject`s in the `SQLQueryObject` model instance returned by the parser, if the `SQLQueryObject` complies with one of the types in the `Class[]` returned by this `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`.

Method Detail

### getProcessCandidateTypes

    java.lang.Class[] getProcessCandidateTypes()

  The candidate types for this `PostParseProcessor`.

  Returns:
    the `SQLQueryObject` types that this `process(SQLQueryObject)` method gets invoked for

### config

    void config(PostParseProcessorConfiguration config)

  Configures this `PostParseProcessor` with the arguments provided in the given `PostParseProcessorConfiguration`.

  Parameters:
    `config` - the configuration arguments that can be consumed by this `PostParseProcessor`

### process

    java.util.List process(SQLQueryObject sqlQuery)
                           throws SQLParserException

  The call back method invoked for each of the `SQLQueryObject`s in the `SQLQueryObject` model instance returned by the parser, if the `SQLQueryObject` complies with one of the types in the `Class[]` returned by this `getProcessCandidateTypes()`

  Parameters:
    `sqlQuery` - instance of one of the types in the `Class[]` returned by `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

    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`. 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.

### getParsedObjectsReplacementMap

    java.util.Map getParsedObjectsReplacementMap()

  Returns a Map containing parsed `SQLQueryObject`s 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 `resetState()` method is called. This method should return a mapping, if during the post parse processing `SQLQueryObject`s 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 `SQLQueryObject`s can be removed from the parser's parsed-element-list and therefore will not be subject to further post parse processing of other `PostParseProcessor`s.
  - key: `SQLQueryObject` originally created by parser
  - value: `SQLQueryObject` created by this `PostParseProcessor` to substitute the originally created by the parser

  Returns:
    Map containing parsed `SQLQueryObject`s mapped to either the `SQLQueryObject` that replaces it to `null`, if that parsed object simply is to be removed