## org.eclipse.ocl.lpg
Class AbstractProblemHandler

    java.lang.Object
      org.eclipse.ocl.lpg.AbstractProblemHandler

All Implemented Interfaces:
  lpg.lpgjavaruntime.ParseErrorCodes, ProblemHandler

Direct Known Subclasses:
  OCLProblemHandler, StringProblemHandler

    public abstract class AbstractProblemHandler

extends Object
implements ProblemHandler, lpg.lpgjavaruntime.ParseErrorCodes

Partial implementation of the `ProblemHandler` API, useful for subclasses to selectively override behaviour.

Nested Class Summary

Nested classes/interfaces inherited from interface org.eclipse.ocl.lpg.ProblemHandler
`ProblemHandler.Phase, ProblemHandler.Severity`

Field Summary

Fields inherited from interface org.eclipse.ocl.lpg.ProblemHandler
`ERROR_MESSAGES`

Fields inherited from interface lpg.lpgjavaruntime.ParseErrorCodes
`BEFORE_CODE, DELETION_CODE, EOF_CODE, ERROR_CODE, errorMsgText, INSERTION_CODE, INVALID_CODE, INVALID_TOKEN_CODE, LEX_ERROR_CODE, MERGE_CODE, MISPLACED_CODE, SCOPE_CODE, SECONDARY_CODE, SUBSTITUTION_CODE`

Constructor Summary
`protected` `AbstractProblemHandler(AbstractParser parser)` Initializes me with the parser that can supply line number locations for problems.

Method Summary
`protected void` `addProblem(String message)` The default implementation just prints the message using `System.out.println`.
`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()` This default implementation does nothing.
`void` `beginValidation()` This default implementation does nothing.
`void` `endParse()` This default implementation does nothing.
`void` `endValidation()` This default implementation does nothing.
`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)` Implements the interface, invoking `addProblem` with a line comprising `processingPhase-problemSeverity in processingContext; lineNumber : problemMessage`.
`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.

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

Constructor Detail

### AbstractProblemHandler

    protected AbstractProblemHandler(AbstractParser parser)

  Initializes me with the parser that can supply line number locations for problems.

  Parameters:
    `parser` - my parser

Method Detail

### addProblem

    protected void addProblem(String message)

  The default implementation just prints the message using `System.out.println`.

  Parameters:
    `message` - the problem description

### analyzerProblem

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

  Description copied from interface: `ProblemHandler`
  Convenience method typically invoking `handleProblem` with a `analyzerProblem` processing phase.

  Specified by:
    `analyzerProblem` in interface `ProblemHandler`
  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

### beginParse

    public void beginParse()

  This default implementation does nothing.

  Specified by:
    `beginParse` in interface `ProblemHandler`

### endParse

    public void endParse()

  This default implementation does nothing.

  Specified by:
    `endParse` in interface `ProblemHandler`

### beginValidation

    public void beginValidation()

  This default implementation does nothing.

  Specified by:
    `beginValidation` in interface `ProblemHandler`

### endValidation

    public void endValidation()

  This default implementation does nothing.

  Specified by:
    `endValidation` in interface `ProblemHandler`

### flush

    public void flush(Monitor monitor)

  Description copied from interface: `ProblemHandler`
  Flush all problems to their recipient. This method allows handlers to batch up error reports into a single composite report or transaction.

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

### setParser

    public void setParser(AbstractParser parser)

  Description copied from interface: `ProblemHandler`
  Define the syntactic parser from which source tokens and text may be obtained.

  Specified by:
    `setParser` in interface `ProblemHandler`

### getParser

    public AbstractParser getParser()

  Description copied from interface: `ProblemHandler`
  Queries the parser from which I obtain source tokens and text.

  Specified by:
    `getParser` in interface `ProblemHandler`
  Returns:
    my parser

### handleProblem

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

  Implements the interface, invoking `addProblem` with a line comprising `processingPhase-problemSeverity in processingContext; lineNumber : problemMessage`.

  Specified by:
    `handleProblem` in interface `ProblemHandler`
  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

### lexerProblem

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

  Description copied from interface: `ProblemHandler`
  Convenience method typically invoking `handleProblem` with a `lexerProblem` processing phase.

  Specified by:
    `lexerProblem` in interface `ProblemHandler`
  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

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

  Description copied from interface: `ProblemHandler`
  Convenience method typically invoking `handleProblem` with a `parserProblem` processing phase.

  Specified by:
    `parserProblem` in interface `ProblemHandler`
  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

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

  Description copied from interface: `ProblemHandler`
  Convenience method typically invoking `handleProblem` with a `utilityProblem` processing phase.

  Specified by:
    `utilityProblem` in interface `ProblemHandler`
  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

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

  Description copied from interface: `ProblemHandler`
  Convenience method typically invoking `handleProblem` with a `validatorProblem` processing phase.

  Specified by:
    `validatorProblem` in interface `ProblemHandler`
  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

    public void setErrorReportLineOffset(int offset)

  Description copied from interface: `ProblemHandler`
  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.

  Specified by:
    `setErrorReportLineOffset` in interface `ProblemHandler`

### getErrorReportLineOffset

    public int getErrorReportLineOffset()

  Description copied from interface: `ProblemHandler`
  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.

  Specified by:
    `getErrorReportLineOffset` in interface `ProblemHandler`
  Returns:
    the line offset

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