org.eclipse.ocl
Class AbstractEnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>

java.lang.Object
  extended by org.eclipse.ocl.AbstractEnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
All Implemented Interfaces:
EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>, Adaptable
Direct Known Subclasses:
EcoreEnvironmentFactory, UMLEnvironmentFactory

public abstract class AbstractEnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
extends java.lang.Object
implements EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>, Adaptable

Partial implementation of the EnvironmentFactory interface, useful for subclassing to define the OCL binding for a metamodel. This abstract class takes care of some of the more common (and mundane) chores, such as:

The subclass's responsibility (in addition to implementing any other interface methods not implemented here) is to define how to:

This class is intended to be extended by clients, for the purpose of implementing metamodel-specific environment factories.

See the EnvironmentFactory class for a description of the generic type parameters of this class.

Author:
Christian W. Damus (cdamus)

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.ocl.EnvironmentFactory
EnvironmentFactory.Lookup<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
 
Constructor Summary
protected AbstractEnvironmentFactory()
          Initializes me.
 
Method Summary
 Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createAttributeContext(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent, P property)
          Creates an environment suitable for parsing OCL expressions on the specified property, which is some attribute in the client's metamodel.
 Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createClassifierContext(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent, C context)
          Creates an environment suitable for parsing OCL expressions in the specified context, which is some classifier in the client's model.
 EvaluationVisitor<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createEvaluationVisitor(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> env, EvaluationEnvironment<C,O,P,CLS,E> evalEnv, java.util.Map<? extends CLS,? extends java.util.Set<? extends E>> extentMap)
          Creates a new evaluation visitor, for the evaluation of OCL expressions.
 Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createInstanceContext(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent, java.lang.Object context)
          Creates an environment suitable for parsing OCL expressions on the specified context object, which is an instance of some classifier in the client's model.
 OCLAnalyzer<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createOCLAnalyzer(AbstractOCLParser parser)
          Creates an instance of the OCLAnalyzer that will use a given parser to perform syntactic and lexical analysis.
 OCLAnalyzer<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createOCLAnalyzer(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> env, java.lang.String input)
          Creates an instance of the OCLAnalyzer that analyzes the given input on behalf of this environment.
 OCLFactoryWithHistory createOCLFactoryWithHistory(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> env)
          Creates an instance of the OCLFactoryWithHistory object for this environment.
 OCLSyntaxHelper createOCLSyntaxHelper(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> env)
          Creates an instance of the OCLSyntaxHelper object for this environment.
 Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createOperationContext(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent, O operation)
          Creates an environment suitable for parsing OCL expressions on the specified operation, which is some operation in the client's metamodel.
 Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createPackageContext(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent, java.util.List<java.lang.String> pathname)
          Creates an environment suitable for parsing OCL expressions in the specified package context.
protected  Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createPackageContext(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent, PK context)
          Creates an environment for the specified package context.
 Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT> createValidationVisitor(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> env)
          Obtains an instance of the validation visitor that validates against the specified environment, which presumably was used in parsing the OCL in the first place.
<T> T
getAdapter(java.lang.Class<T> adapterType)
          The abstract environment factory implementation is adaptable.
protected abstract  C getClassifier(java.lang.Object context)
          Obtains client metamodel's classifier for the specified context object, which may be an instance of a classifier in the user model or may actually be a classifier in the user model.
protected  boolean isEvaluationTracingEnabled()
          Queries whether tracing of evaluation is enabled.
protected abstract  PK lookupPackage(java.util.List<java.lang.String> pathname)
          Looks up the package identified by the specified qualified name by whatever means is appropriate to the particular environment implementation.
protected  void setEvaluationTracingEnabled(boolean b)
          Sets whether tracing of evaluation is enabled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.ocl.EnvironmentFactory
createEnvironment, createEnvironment, createEvaluationEnvironment, createEvaluationEnvironment, loadEnvironment
 

Constructor Detail

AbstractEnvironmentFactory

protected AbstractEnvironmentFactory()
Initializes me.

Method Detail

createPackageContext

protected Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createPackageContext(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent,
                                                                              PK context)
Creates an environment for the specified package context.

Parameters:
parent - the parent environment of the environment to be created
context - the package context (must not be null)
Returns:
the new nested environment

createPackageContext

public Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createPackageContext(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent,
                                                                           java.util.List<java.lang.String> pathname)
Description copied from interface: EnvironmentFactory
Creates an environment suitable for parsing OCL expressions in the specified package context. This context will become a classifier context when the "self" variable is defined.

Specified by:
createPackageContext in interface EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
pathname - the qualified package name (the "::"-separated parts)
Returns:
the environment or null if lookup fails to locate a package
See Also:
EnvironmentFactory.createClassifierContext(org.eclipse.ocl.Environment, C), EnvironmentFactory.createOperationContext(org.eclipse.ocl.Environment, O), EnvironmentFactory.createAttributeContext(org.eclipse.ocl.Environment, P)

lookupPackage

protected abstract PK lookupPackage(java.util.List<java.lang.String> pathname)
Looks up the package identified by the specified qualified name by whatever means is appropriate to the particular environment implementation.

Parameters:
pathname - the qualified name of the package to find
Returns:
the matching package, or null if none is found

createClassifierContext

public Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createClassifierContext(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent,
                                                                              C context)
Description copied from interface: EnvironmentFactory
Creates an environment suitable for parsing OCL expressions in the specified context, which is some classifier in the client's model.

Specified by:
createClassifierContext in interface EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
context - the context classifier
Returns:
the environment
See Also:
EnvironmentFactory.createOperationContext(Environment, Object), EnvironmentFactory.createAttributeContext(Environment, Object), EnvironmentFactory.createInstanceContext(Environment, Object)

createInstanceContext

public Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createInstanceContext(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent,
                                                                            java.lang.Object context)
Description copied from interface: EnvironmentFactory
Creates an environment suitable for parsing OCL expressions on the specified context object, which is an instance of some classifier in the client's model.

The context may be an instance of a model class or a data type value on which an OCL expression would be evaluated. Note that the actual OCL context classifier (as an OCL type or classifier) will be inferred from the context instance according to the metamodel that the environment factory supports, if possible. If not possible, then the OclAny type is assumed.

Specified by:
createInstanceContext in interface EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
context - the context object or value
Returns:
the environment
See Also:
EnvironmentFactory.createClassifierContext(Environment, Object), OCLStandardLibrary.getOclAny()

createOperationContext

public Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createOperationContext(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent,
                                                                             O operation)
Description copied from interface: EnvironmentFactory
Creates an environment suitable for parsing OCL expressions on the specified operation, which is some operation in the client's metamodel. Note that operation contexts can be defined in the context of any classifier to which that operation is applicable.

Specified by:
createOperationContext in interface EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
Parameters:
parent - the parent environment, defining the classifier context
operation - an operation in the client's metamodel
Returns:
the environment
See Also:
EnvironmentFactory.createClassifierContext(Environment, Object)

createAttributeContext

public Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createAttributeContext(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent,
                                                                             P property)
Description copied from interface: EnvironmentFactory
Creates an environment suitable for parsing OCL expressions on the specified property, which is some attribute in the client's metamodel. Note that attribute contexts can be defined in the context of any classifier in which that attribute is available.

Specified by:
createAttributeContext in interface EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
Parameters:
parent - the parent environment, defining the classifier context
property - an attribute in the client's metamodel
Returns:
the environment
See Also:
EnvironmentFactory.createClassifierContext(Environment, Object)

createEvaluationVisitor

public EvaluationVisitor<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createEvaluationVisitor(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> env,
                                                                                    EvaluationEnvironment<C,O,P,CLS,E> evalEnv,
                                                                                    java.util.Map<? extends CLS,? extends java.util.Set<? extends E>> extentMap)
Description copied from interface: EnvironmentFactory
Creates a new evaluation visitor, for the evaluation of OCL expressions.

Specified by:
createEvaluationVisitor in interface EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
Parameters:
env - the environment in which the expression was originally parsed (or some compatible environment)
evalEnv - the evaluation environment that the visitor is to use for tracking variables, navigating properties, etc.
extentMap - the map of Classes to their extends
Returns:
the new evaluation visitor

createOCLAnalyzer

public OCLAnalyzer<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createOCLAnalyzer(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> env,
                                                                        java.lang.String input)
Description copied from interface: EnvironmentFactory
Creates an instance of the OCLAnalyzer that analyzes the given input on behalf of this environment.

Specified by:
createOCLAnalyzer in interface EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
input - the text to be analyzed
Returns:
an OCLAnalyzer instance for this environment
Since:
3.1

createOCLAnalyzer

public OCLAnalyzer<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> createOCLAnalyzer(AbstractOCLParser parser)
Description copied from interface: EnvironmentFactory
Creates an instance of the OCLAnalyzer that will use a given parser to perform syntactic and lexical analysis.

Specified by:
createOCLAnalyzer in interface EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
Parameters:
parser - performing syntax analysis
Returns:
an OCLAnalyzer instance for this environment
Since:
3.1

createOCLFactoryWithHistory

public OCLFactoryWithHistory createOCLFactoryWithHistory(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> env)
Description copied from interface: EnvironmentFactory
Creates an instance of the OCLFactoryWithHistory object for this environment.

Specified by:
createOCLFactoryWithHistory in interface EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
Returns:
an OCLFactoryWithHistory instance for this environment
Since:
3.1

createOCLSyntaxHelper

public OCLSyntaxHelper createOCLSyntaxHelper(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> env)
Description copied from interface: EnvironmentFactory
Creates an instance of the OCLSyntaxHelper object for this environment.

Specified by:
createOCLSyntaxHelper in interface EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
Parameters:
env - an OCL environment (must not be null)
Returns:
an OCLSyntaxHelper instance for this environment
Since:
3.1

createValidationVisitor

public Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT> createValidationVisitor(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> env)
Description copied from interface: EnvironmentFactory
Obtains an instance of the validation visitor that validates against the specified environment, which presumably was used in parsing the OCL in the first place.

Specified by:
createValidationVisitor in interface EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
Parameters:
env - an OCL environment (must not be null)
Returns:
a validation visitor instance for the specified environment
Since:
3.1

getClassifier

protected abstract C getClassifier(java.lang.Object context)
Obtains client metamodel's classifier for the specified context object, which may be an instance of a classifier in the user model or may actually be a classifier in the user model.

Parameters:
context - a context object or classifier
Returns:
the user model's classifier for this context object, or the context itself if it is a classifier

isEvaluationTracingEnabled

protected boolean isEvaluationTracingEnabled()
Queries whether tracing of evaluation is enabled. Tracing logs the progress of evaluation to the console, which may be of use in diagnosing problems.

In an Eclipse environment, tracing is also enabled by turning on the org.eclipse.ocl/debug/evaluation debug option.

Returns:
whether evaluation tracing is enabled
See Also:
setEvaluationTracingEnabled(boolean)

setEvaluationTracingEnabled

protected void setEvaluationTracingEnabled(boolean b)
Sets whether tracing of evaluation is enabled. Tracing logs the progress of parsing to the console, which may be of use in diagnosing problems.

In an Eclipse environment, tracing is also enabled by turning on the org.eclipse.ocl/debug/evaluation debug option.

param b whether evaluation tracing is enabled

See Also:
isEvaluationTracingEnabled()

getAdapter

public <T> T getAdapter(java.lang.Class<T> adapterType)
The abstract environment factory implementation is adaptable. The default implementation adapts to and interface actually implemented by the receiver.

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
Since:
1.2