## org.eclipse.ocl.lpg
Class AbstractBasicEnvironment

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

All Implemented Interfaces:
  BasicEnvironment, BasicEnvironment2, Customizable, Adaptable

Direct Known Subclasses:
  AbstractEnvironment

    public abstract class AbstractBasicEnvironment

extends Object
implements BasicEnvironment2

Partial implementation of the `BasicEnvironment` interface, providing default behaviours for most features.

Since:
  1.2

Constructor Summary
`protected` `AbstractBasicEnvironment(BasicEnvironment parent)` Initializes me with the specified parent environment, which should be of the same type as me.

Method Summary
`void` `analyzerError(String problemMessage, String problemContext, int startOffset, int endOffset)` Convenience method invoking `getProblemHandler().analyzerProblem` with a `ProblemHandler.errorSeverity`.
`void` `analyzerError(String problemMessage, String problemContext, List<?> problemObjects)` Convenience method invoking `getProblemHandler().analyzerProblem` with a `ProblemHandler.errorSeverity`.
`void` `analyzerError(String problemMessage, String problemContext, Object problemObject)` Convenience method invoking `getProblemHandler().analyzerProblem` with a `ProblemHandler.errorSeverity`.
`void` `analyzerWarning(String problemMessage, String problemContext, Object problemObject)` Convenience method invoking `getProblemHandler().analyzerProblem` with a `ProblemHandler.warningSeverity`.
`protected Map<Option<?>,Object>` `basicGetOptions()`
`Map<Option<?>,Object>` `clearOptions()` Clears all options.
`protected ProblemHandler` `createDefaultProblemHandler(AbstractParser parser)`
`protected FormattingHelper` `createFormattingHelper()` Obtains the new or existing formatting-helper for this environment to use.

`

`<T> T`

`

`getAdapter(Class<T> adapterType)`
The abstract environment implementation is adaptable.

`CSTNode` `getASTMapping(Object object)` Return the mapping of an astNode to its originating cstNode, so that AST-based analysis may report error messages exploiting the CST context, or to support incremental AST/CST update.
`Map<Object,CSTNode>` `getASTNodeToCSTNodeMap()`
`FormattingHelper` `getFormatter()` Return the message formatter that may be used to format object-related contributions to problem messages.
`Map<Option<?>,Object>` `getOptions()` Obtains a copy of my map of options.
`BasicEnvironment` `getParent()`
`AbstractParser` `getParser()` Return the syntactic parser from which source tokens and text amy be obtained.
`ProblemHandler` `getProblemHandler()` Obtains a problem handler to service lexer, parser, analyzer, validator, ... errors.

`

`<T> T`

`

`getValue(Option<T> option)`
Obtains the value of the specified option's setting in the my options map.

`void` `initASTMapping(Object astNode, CSTNode cstNode)` Initialize the mapping of an object (typically an astNode) to its originating cstNode, so that AST-based analysis may report error messages exploiting the CST context, or to support incremental AST/CST update.
`void` `initASTMapping(Object fromAstNode, CSTNode cstNode, Object toAstNode)` Initialize the asymmetric mapping of an object (typically an astNode) to its originating cstNode, and of a cstNode to its consequent object (typically an astNode) so that AST-based analysis may report error messages exploiting the CST context, or to support incremental AST/CST update.
`boolean` `isEnabled(Option<Boolean> option)` Queries whether the specified boolean-valued option is enabled.
`void` `lexerError(int errorCode, int startOffset, int endOffset)` Convenience method invoking `getProblemHandler().lexerProblem` with a `ProblemHandler.errorSeverity`.
`void` `parserError(int errorCode, int leftToken, int rightToken, String tokenText)` Convenience method invoking `getProblemHandler().parserProblem` with a `ProblemHandler.errorSeverity`.
`void` `problem(ProblemHandler.Severity severity, ProblemHandler.Phase phase, String problemMessage, String problemContext, Object problemObject)` Generically reports a problem about some object.

`

`<T> void`

`

`putOptions(Map<? extends Option<T>,? extends T> options)`
Adds options to apply to my behaviour.

`

`<T> T`

`

`removeOption(Option<T> option)`
Removes the specified option.

`

`<T> Map<Option<T>,T>`

`

`removeOptions(Collection<Option<T>> options)`
Removes the specified options.

`void` `setASTNodeToCSTNodeMap(Map<Object,CSTNode> astNodeToCstNodeMap)`

`

`<T> void`

`

`setOption(Option<T> option, T value)`
Add an option to apply to my behaviour.

`protected void` `setParent(BasicEnvironment parent)` Assigns me a parent environment after construction.
`void` `setParser(AbstractParser parser)` Define the syntactic parser from which source tokens and text amy be obtained.
`ProblemHandler` `setProblemHandler(ProblemHandler newProblemHandler)` Define the handler for any problem reports.
`void` `utilityError(String problemMessage, String problemContext, Object problemObject)` Convenience method invoking `getProblemHandler().utilityProblem` with a `ProblemHandler.errorSeverity`.
`void` `validatorError(String problemMessage, String problemContext, Object problemObject)` Convenience method invoking `getProblemHandler().validatorProblem` with a `ProblemHandler.errorSeverity`.

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

Constructor Detail

### AbstractBasicEnvironment

    protected AbstractBasicEnvironment(BasicEnvironment parent)

  Initializes me with the specified parent environment, which should be of the same type as me.

  Parameters:
    `parent` - an environment of the same type as me (or `null`)

Method Detail

### getAdapter

    public <T> T getAdapter(Class<T> adapterType)

  The abstract environment implementation is adaptable. The default implementation adapts to and interface actually implemented by the receiver in addition to the `ProblemHandler` interface.

  Subclasses may override or extend this implementation.

  Specified by:
    `getAdapter` in interface `Adaptable`
  Type Parameters:
    `T` - the requested adapter interface
  Parameters:
    `adapterType` - the requested adapter interface
  Returns:
    an instance of the requested interface, or `null` if this environment does not adapt to it

### analyzerError

    public void analyzerError(String problemMessage,
                              String problemContext,
                              Object problemObject)

  Description copied from interface: `BasicEnvironment`
  Convenience method invoking `getProblemHandler().analyzerProblem` with a `ProblemHandler.errorSeverity`.

  Specified by:
    `analyzerError` in interface `BasicEnvironment`
  Parameters:
    `problemMessage` - message describing the problem
    `problemContext` - optional message describing the reporting context
    `problemObject` - optional object associated with the problem

### analyzerError

    public void analyzerError(String problemMessage,
                              String problemContext,
                              List<?> problemObjects)

  Description copied from interface: `BasicEnvironment`
  Convenience method invoking `getProblemHandler().analyzerProblem` with a `ProblemHandler.errorSeverity`.

  Specified by:
    `analyzerError` in interface `BasicEnvironment`
  Parameters:
    `problemMessage` - message describing the problem
    `problemContext` - optional message describing the reporting context
    `problemObjects` - optional sequence of objects associated with the problem

### analyzerError

    public void analyzerError(String problemMessage,
                              String problemContext,
                              int startOffset,
                              int endOffset)

  Description copied from interface: `BasicEnvironment`
  Convenience method invoking `getProblemHandler().analyzerProblem` with a `ProblemHandler.errorSeverity`.

  Specified by:
    `analyzerError` in interface `BasicEnvironment`
  Parameters:
    `problemMessage` - message describing the problem
    `problemContext` - optional message describing the reporting context
    `startOffset` - character index at the start of the error
    `endOffset` - character index beyond the end of the error

### analyzerWarning

    public void analyzerWarning(String problemMessage,
                                String problemContext,
                                Object problemObject)

  Description copied from interface: `BasicEnvironment`
  Convenience method invoking `getProblemHandler().analyzerProblem` with a `ProblemHandler.warningSeverity`.

  Specified by:
    `analyzerWarning` in interface `BasicEnvironment`
  Parameters:
    `problemMessage` - message describing the problem
    `problemContext` - optional message describing the reporting context
    `problemObject` - optional object associated with the problem

### createDefaultProblemHandler

    protected ProblemHandler createDefaultProblemHandler(AbstractParser parser)

### getParent

    public BasicEnvironment getParent()

### getParser

    public AbstractParser getParser()

  Description copied from interface: `BasicEnvironment`
  Return the syntactic parser from which source tokens and text amy be obtained.

  Specified by:
    `getParser` in interface `BasicEnvironment`
  Returns:
    parser

### getASTNodeToCSTNodeMap

    public Map<Object,CSTNode> getASTNodeToCSTNodeMap()

### getASTMapping

    public CSTNode getASTMapping(Object object)

  Description copied from interface: `BasicEnvironment`
  Return the mapping of an astNode to its originating cstNode, so that AST-based analysis may report error messages exploiting the CST context, or to support incremental AST/CST update.

  Specified by:
    `getASTMapping` in interface `BasicEnvironment`
  Returns:
    cstNode

### getFormatter

    public FormattingHelper getFormatter()

  Description copied from interface: `BasicEnvironment`
  Return the message formatter that may be used to format object-related contributions to problem messages.

  Specified by:
    `getFormatter` in interface `BasicEnvironment`
  Returns:
    non-null message formatter

### createFormattingHelper

    protected FormattingHelper createFormattingHelper()

  Obtains the new or existing formatting-helper for this environment to use. This default implementation returns the shared `AbstractFormattingHelper`; subclasses may override.

  Returns:
    a new formatting helper
  Since:
    1.3

### getProblemHandler

    public ProblemHandler getProblemHandler()

  Description copied from interface: `BasicEnvironment`
  Obtains a problem handler to service lexer, parser, analyzer, validator, ... errors.

  Specified by:
    `getProblemHandler` in interface `BasicEnvironment`
  Returns:
    the problem handler.

### initASTMapping

    public void initASTMapping(Object astNode,
                               CSTNode cstNode)

  Description copied from interface: `BasicEnvironment`
  Initialize the mapping of an object (typically an astNode) to its originating cstNode, so that AST-based analysis may report error messages exploiting the CST context, or to support incremental AST/CST update.

  Specified by:
    `initASTMapping` in interface `BasicEnvironment`

### initASTMapping

    public void initASTMapping(Object fromAstNode,
                               CSTNode cstNode,
                               Object toAstNode)

  Description copied from interface: `BasicEnvironment2`
  Initialize the asymmetric mapping of an object (typically an astNode) to its originating cstNode, and of a cstNode to its consequent object (typically an astNode) so that AST-based analysis may report error messages exploiting the CST context, or to support incremental AST/CST update. Any pre-existing mapping is preserved. Each mapping involving a null object is ignored, so that for instance the toAstNode may be set null to establish only the fromAstNode to cstNode mapping.

  Specified by:
    `initASTMapping` in interface `BasicEnvironment2`
  Parameters:
    `fromAstNode` - source of the AST-to-CST mapping
    `cstNode` - target of the AST-to-CST mapping and source of the CST-to-AST mapping
    `toAstNode` - target of the CST-to-AST mapping
  Since:
    1.3

### lexerError

    public void lexerError(int errorCode,
                           int startOffset,
                           int endOffset)

  Description copied from interface: `BasicEnvironment`
  Convenience method invoking `getProblemHandler().lexerProblem` with a `ProblemHandler.errorSeverity`.

  Specified by:
    `lexerError` in interface `BasicEnvironment`
  Parameters:
    `errorCode` - the ParserErrorCodes value identifying the error
    `startOffset` - character index at the start of the error
    `endOffset` - character index beyond the end of the error

### parserError

    public void parserError(int errorCode,
                            int leftToken,
                            int rightToken,
                            String tokenText)

  Description copied from interface: `BasicEnvironment`
  Convenience method invoking `getProblemHandler().parserProblem` with a `ProblemHandler.errorSeverity`.

  Specified by:
    `parserError` in interface `BasicEnvironment`
  Parameters:
    `errorCode` - the ParserErrorCodes value identifying the error
    `leftToken` - the lexical token index at the left hand edge of the error
    `rightToken` - the lexical token index at the right hand edge of the error
    `tokenText` - additional text apprropriate to the ParserErrorCodes value.

### setASTNodeToCSTNodeMap

    public void setASTNodeToCSTNodeMap(Map<Object,CSTNode> astNodeToCstNodeMap)

### setParent

    protected void setParent(BasicEnvironment parent)

  Assigns me a parent environment after construction. It is not advisable to set the parent to `null` if I previously had one.

  Parameters:
    `parent` - my new parent

### setParser

    public void setParser(AbstractParser parser)

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

  Specified by:
    `setParser` in interface `BasicEnvironment`

### setProblemHandler

    public ProblemHandler setProblemHandler(ProblemHandler newProblemHandler)

  Description copied from interface: `BasicEnvironment`
  Define the handler for any problem reports.

  Specified by:
    `setProblemHandler` in interface `BasicEnvironment`
  Returns:
    the previous problem handler

### utilityError

    public void utilityError(String problemMessage,
                             String problemContext,
                             Object problemObject)

  Description copied from interface: `BasicEnvironment`
  Convenience method invoking `getProblemHandler().utilityProblem` with a `ProblemHandler.errorSeverity`.

  Specified by:
    `utilityError` in interface `BasicEnvironment`
  Parameters:
    `problemMessage` - message describing the problem
    `problemContext` - optional message describing the reporting context
    `problemObject` - optional object associated with the problem

### validatorError

    public void validatorError(String problemMessage,
                               String problemContext,
                               Object problemObject)

  Description copied from interface: `BasicEnvironment`
  Convenience method invoking `getProblemHandler().validatorProblem` with a `ProblemHandler.errorSeverity`.

  Specified by:
    `validatorError` in interface `BasicEnvironment`
  Parameters:
    `problemMessage` - message describing the problem
    `problemContext` - optional message describing the reporting context
    `problemObject` - optional object associated with the problem

### problem

    public void problem(ProblemHandler.Severity severity,
                        ProblemHandler.Phase phase,
                        String problemMessage,
                        String problemContext,
                        Object problemObject)

  Description copied from interface: `BasicEnvironment`
  Generically reports a problem about some object.

  Specified by:
    `problem` in interface `BasicEnvironment`
  Parameters:
    `severity` - the severity of the problem
    `phase` - the phase in which the problem was encountered
    `problemMessage` - message describing the problem
    `problemContext` - optional message describing the reporting context
    `problemObject` - optional object associated with the problem

### basicGetOptions

    protected Map<Option<?>,Object> basicGetOptions()

### getOptions

    public Map<Option<?>,Object> getOptions()

  Description copied from interface: `Customizable`
  Obtains a copy of my map of options. Options not explicitly set in an environment are inherited from the parent environment, if any, otherwise they are at their default values.

  Specified by:
    `getOptions` in interface `Customizable`
  Returns:
    the map of options

### setOption

    public <T> void setOption(Option<T> option,
                              T value)

  Description copied from interface: `Customizable`
  Add an option to apply to my behaviour.

  Specified by:
    `setOption` in interface `Customizable`
  Parameters:
    `option` - the option
    `value` - the option's value

### putOptions

    public <T> void putOptions(Map<? extends Option<T>,? extends T> options)

  Description copied from interface: `Customizable`
  Adds options to apply to my behaviour.

  Specified by:
    `putOptions` in interface `Customizable`
  Parameters:
    `options` - the options

### removeOption

    public <T> T removeOption(Option<T> option)

  Description copied from interface: `Customizable`
  Removes the specified option.

  Specified by:
    `removeOption` in interface `Customizable`
  Parameters:
    `option` - the option to remove
  Returns:
    the former value of the option

### removeOptions

    public <T> Map<Option<T>,T> removeOptions(Collection<Option<T>> options)

  Description copied from interface: `Customizable`
  Removes the specified options.

  Specified by:
    `removeOptions` in interface `Customizable`
  Parameters:
    `options` - the options to remove
  Returns:
    the former values of the options

### clearOptions

    public Map<Option<?>,Object> clearOptions()

  Description copied from interface: `Customizable`
  Clears all options.

  Specified by:
    `clearOptions` in interface `Customizable`
  Returns:
    the former values of the options

### isEnabled

    public boolean isEnabled(Option<Boolean> option)

  Description copied from interface: `Customizable`
  Queries whether the specified boolean-valued option is enabled. This method essentially just puts a nice "is" name on boolean options. Options not explicitly set in an environment are inherited from the parent environment, if any, otherwise they are at their default values.

  Specified by:
    `isEnabled` in interface `Customizable`
  Parameters:
    `option` - an option
  Returns:
    whether the option is enabled

### getValue

    public <T> T getValue(Option<T> option)

  Description copied from interface: `Customizable`
  Obtains the value of the specified option's setting in the my options map. Options not explicitly set in an environment are inherited from the parent environment, if any, otherwise they are at their default values.

  Specified by:
    `getValue` in interface `Customizable`
  Parameters:
    `option` - the option to query
  Returns:
    value of the option

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