## org.eclipse.ocl.lpg
Interface ProblemHandler

All Known Implementing Classes:
  AbstractProblemHandler, OCLProblemHandler, ProblemHandlerWrapper, ProblemHandlerWrapper.Tee, StringProblemHandler

    public interface ProblemHandler

A `ProblemHandler` handles problems detected during the various lexical syntactic, semantic analysis and validation phases of source text processing. `setParser` should be invoked once the source text is available, then `handleProblem` for each problem and finally `flush` to send any accumulated problems to an appropriate recipient such as an error log or problem marker view. See `AbstractProblemHandler` for a default implementation of the per processing phase convenience methods and `StringProblemHandler` for a complete handler that just accumulates all problem reports as a string.

Nested Class Summary
`static class` `ProblemHandler.Phase` Standard processing phases for problem messages.
`static class` `ProblemHandler.Severity` Standard problem severities.

Field Summary
`static String[]` `ERROR_MESSAGES`

Method Summary
`void` `analyzerProblem(ProblemHandler.Severity problemSeverity, String problemMessage, String processingContext, int startOffset, int endOffset)` Convenience method typically invoking `handleProblem` with a `analyzerProblem` processing phase.
`void` `beginParse()` Notifies me that parsing is about to begin, from which I may receive problems.
`void` `beginValidation()` Notifies me that validation is about to begin, from which I may receive problems.
`void` `endParse()` Notifies me that parsing has completed, and I will get no further problems in this session.
`void` `endValidation()` Notifies me that validation has completed, and I will get no further problems in this session.
`void` `flush(Monitor monitor)` Flush all problems to their recipient.
`int` `getErrorReportLineOffset()` Queries the line offset for reporting errors.
`AbstractParser` `getParser()` Queries the parser from which I obtain source tokens and text.

`void`

`handleProblem(ProblemHandler.Severity problemSeverity, ProblemHandler.Phase processingPhase, String problemMessage, String processingContext, int startOffset, int endOffset)`
Handle a problem of problemSeverity that has arisen during processingPhase and which is explained by problemMessage optionally clarified, if non-null, by processingContext, and if non-negative by the startOffset and endOffset character indexes in the parsing stream.

`void` `lexerProblem(ProblemHandler.Severity problemSeverity, String problemMessage, String processingContext, int startOffset, int endOffset)` Convenience method typically invoking `handleProblem` with a `lexerProblem` processing phase.
`void` `parserProblem(ProblemHandler.Severity problemSeverity, String problemMessage, String processingContext, int startOffset, int endOffset)` Convenience method typically invoking `handleProblem` with a `parserProblem` processing phase.
`void` `setErrorReportLineOffset(int offset)` Sets the line offset for reporting errors.
`void` `setParser(AbstractParser parser)` Define the syntactic parser from which source tokens and text may be obtained.
`void` `utilityProblem(ProblemHandler.Severity problemSeverity, String problemMessage, String processingContext, int startOffset, int endOffset)` Convenience method typically invoking `handleProblem` with a `utilityProblem` processing phase.
`void` `validatorProblem(ProblemHandler.Severity problemSeverity, String problemMessage, String processingContext, int startOffset, int endOffset)` Convenience method typically invoking `handleProblem` with a `validatorProblem` processing phase.

Field Detail

### ERROR_MESSAGES

    static final String[] ERROR_MESSAGES

Method Detail

### setParser

    void setParser(AbstractParser parser)

  Define the syntactic parser from which source tokens and text may be obtained.

  Parameters:
    `parser` -

### getParser

    AbstractParser getParser()

  Queries the parser from which I obtain source tokens and text.

  Returns:
    my parser

### handleProblem

    void handleProblem(ProblemHandler.Severity problemSeverity,
                       ProblemHandler.Phase processingPhase,
                       String problemMessage,
                       String processingContext,
                       int startOffset,
                       int endOffset)

  Handle a problem of problemSeverity that has arisen during processingPhase and which is explained by problemMessage optionally clarified, if non-null, by processingContext, and if non-negative by the startOffset and endOffset character indexes in the parsing stream. All other problem handling messages should redirect to this method.

  Parameters:
    `problemSeverity` - text describing the problem severity (e.g. `errorSeverity`)
    `processingPhase` - optional text describing the processing phase (e.g. `analyzerProblem`)
    `problemMessage` - message describing the problem
    `processingContext` - optional message describing the reporting context (e.g. `"PathNameCS"`)
    `startOffset` - (inclusive) index of first source character influencing the problem, -ve if unknown
    `endOffset` - (exclusive) index of last source character influencing the problem, -ve if unknown

### analyzerProblem

    void analyzerProblem(ProblemHandler.Severity problemSeverity,
                         String problemMessage,
                         String processingContext,
                         int startOffset,
                         int endOffset)

  Convenience method typically invoking `handleProblem` with a `analyzerProblem` processing phase.

  Parameters:
    `problemSeverity` - text describing the problem severity
    `problemMessage` - message describing the problem
    `processingContext` - optional message describing the reporting context (e.g. `"PathNameCS"`)
    `startOffset` - (inclusive) index of first source character influencing the problem, -ve if unknown
    `endOffset` - (exclusive) index of last source character influencing the problem, -ve if unknown

### lexerProblem

    void lexerProblem(ProblemHandler.Severity problemSeverity,
                      String problemMessage,
                      String processingContext,
                      int startOffset,
                      int endOffset)

  Convenience method typically invoking `handleProblem` with a `lexerProblem` processing phase.

  Parameters:
    `problemSeverity` - text describing the problem severity
    `problemMessage` - message describing the problem
    `processingContext` - optional message describing the reporting context (e.g. `"PathNameCS"`)
    `startOffset` - (inclusive) index of first source character influencing the problem, -ve if unknown
    `endOffset` - (exclusive) index of last source character influencing the problem, -ve if unknown

### parserProblem

    void parserProblem(ProblemHandler.Severity problemSeverity,
                       String problemMessage,
                       String processingContext,
                       int startOffset,
                       int endOffset)

  Convenience method typically invoking `handleProblem` with a `parserProblem` processing phase.

  Parameters:
    `problemSeverity` - text describing the problem severity
    `problemMessage` - message describing the problem
    `processingContext` - optional message describing the reporting context (e.g. `"PathNameCS"`)
    `startOffset` - (inclusive) index of first source character influencing the problem, -ve if unknown
    `endOffset` - (exclusive) index of last source character influencing the problem, -ve if unknown

### utilityProblem

    void utilityProblem(ProblemHandler.Severity problemSeverity,
                        String problemMessage,
                        String processingContext,
                        int startOffset,
                        int endOffset)

  Convenience method typically invoking `handleProblem` with a `utilityProblem` processing phase.

  Parameters:
    `problemSeverity` - text describing the problem severity
    `problemMessage` - message describing the problem
    `processingContext` - optional message describing the reporting context (e.g. `"PathNameCS"`)
    `startOffset` - (inclusive) index of first source character influencing the problem, -ve if unknown
    `endOffset` - (exclusive) index of last source character influencing the problem, -ve if unknown

### validatorProblem

    void validatorProblem(ProblemHandler.Severity problemSeverity,
                          String problemMessage,
                          String processingContext,
                          int startOffset,
                          int endOffset)

  Convenience method typically invoking `handleProblem` with a `validatorProblem` processing phase.

  Parameters:
    `problemSeverity` - text describing the problem severity
    `problemMessage` - message describing the problem
    `processingContext` - optional message describing the reporting context (e.g. `"PathNameCS"`)
    `startOffset` - (inclusive) index of first source character influencing the problem, -ve if unknown
    `endOffset` - (exclusive) index of last source character influencing the problem, -ve if unknown

### setErrorReportLineOffset

    void setErrorReportLineOffset(int offset)

  Sets the line offset for reporting errors. E.g,. if an error occurred at line 2, but the offset was set to -1, then line 1 will be reported.

  Parameters:
    `offset` -

### getErrorReportLineOffset

    int getErrorReportLineOffset()

  Queries the line offset for reporting errors. E.g,. if an error occurred at line 2, but the offset was set to -1, then line 1 will be reported.

  Returns:
    the line offset

### beginParse

    void beginParse()

  Notifies me that parsing is about to begin, from which I may receive problems. I should initialize myself accordingly, if necessary.

### endParse

    void endParse()

  Notifies me that parsing has completed, and I will get no further problems in this session. I may clean up accordingly, if necessary.

### beginValidation

    void beginValidation()

  Notifies me that validation is about to begin, from which I may receive problems. I should initialize myself accordingly, if necessary.

### endValidation

    void endValidation()

  Notifies me that validation has completed, and I will get no further problems in this session. I may clean up accordingly, if necessary.

### flush

    void flush(Monitor monitor)

  Flush all problems to their recipient. This method allows handlers to batch up error reports into a single composite report or transaction.

  Parameters:
    `monitor` - an optional EMF monitor for reporting progress. May be `null` if not needed by the caller

Copyright 2002, 2007 IBM Corporation and others. All Rights Reserved.