public abstract class AbstractEnvironment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> extends AbstractBasicEnvironment implements Environment.Internal<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>, Environment.Lookup<PK,C,O,P>
Environment
interface providing
some useful common behavior for providers of metamodel bindings. It is
recommended to extend this class rather than to implement the
Environment
interface from scratch.
In particular, this class provides:
along with some subclass hook methods and convenience methods.
See the Environment
class for a description of the
generic type parameters of this class.
Environment.Internal<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>, Environment.Lookup<PK,C,O,P>, Environment.Registry
OCL_NAMESPACE_URI, RESULT_VARIABLE_NAME, SELF_VARIABLE_NAME
Modifier and Type | Method and Description |
---|---|
boolean |
addElement(String name,
Variable<C,PM> elem,
boolean isExplicit)
Adds a variable declaration to the environment.
|
void |
addHelperOperation(C owner,
O operation)
Adds an OCL-defined additional ("helper") operation to
the environment.
|
void |
addHelperProperty(C owner,
P property)
Adds an OCL-defined additional ("helper") attribute to
the environment.
|
void |
deleteElement(String name)
Removes a variable when it goes out of scope.
|
void |
dispose()
I dispose my type resolver, if it is an
AbstractTypeResolver
and I am the root environment (which owns the resolver). |
<T> T |
getAdapter(Class<T> adapterType)
Since
AbstractTypeResolver implements TypeChecker ,
AbstractEnvironment will try to adapt TypeChecker , via its
TypeResolver . |
List<P> |
getAdditionalAttributes(C classifier)
Obtains the additional attributes defined in this environment in the
context of the specified classifier.
|
List<O> |
getAdditionalOperations(C classifier)
Obtains the additional operations defined in this environment in the
context of the specified classifier.
|
CT |
getBodyCondition(O operation)
Obtains an operation's body condition constraint.
|
C |
getContextClassifier()
Obtains the context classifier of this environment.
|
O |
getContextOperation()
Obtains the context operation of this environment, if it is an operation
context.
|
PK |
getContextPackage()
Obtains my context package, if any.
|
P |
getContextProperty()
Obtains the context property of this environment, if it is a property
context.
|
CT |
getDeriveConstraint(P property)
Obtains a property's derived-value constraint.
|
CT |
getInitConstraint(P property)
Obtains a property's with an initial-value constraint, if any.
|
Environment.Internal<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> |
getInternalParent()
Obtains my parent environment after construction.
|
AbstractEnvironment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> |
getParent()
Deprecated.
Since 1.2, use the
getInternalParent() method, instead. |
Variable<C,PM> |
getSelfVariable()
Gets the self variable, looking it up in a parent environment if necessary.
|
Collection<Variable<C,PM>> |
getVariables()
Returns the
Variable s registered explicitly in me and any
parents that I may have. |
boolean |
isEmpty()
Queries whether the environment has any local variables defined in it.
|
Variable<C,PM> |
lookup(String name)
Obtains the Variable bound to a variable name.
|
C |
lookupAssociationClassReference(C owner,
String name)
Finds a reference in the specified class to the named association class.
|
Variable<C,PM> |
lookupImplicitSourceForAssociationClass(String name)
Return an implicit variable that references the
named association class.
|
Variable<C,PM> |
lookupImplicitSourceForOperation(String name,
List<? extends TypedElement<C>> args)
Return an implicit variable declaration that defines the specified
operation signature.
|
Variable<C,PM> |
lookupImplicitSourceForProperty(String name)
Return the most appropriate matching variable to use as the implicit
source of a call to the specified property.
|
Variable<C,PM> |
lookupImplicitSourceForSignal(String name,
List<? extends TypedElement<C>> args)
Return an implicit variable declaration that defines the specified
signal reception signature.
|
Variable<C,PM> |
lookupImplicitSourceForState(List<String> path)
Finds the best-matching implicit variable to use as a source for
the unqualified oclIsInState() invocation with the specified
state qualified name path.
|
Variable<C,PM> |
lookupLocal(String name)
Obtains the Variable bound to a local variable name.
|
O |
lookupOperation(C owner,
String name,
List<? extends TypedElement<C>> args)
Find an operation in the specified class.
|
P |
lookupProperty(C owner,
String name)
Finds a property defined or inherited by the specified classifier.
|
C |
lookupSignal(C owner,
String name,
List<? extends TypedElement<C>> args)
Finds a received signal in the specified classifier.
|
S |
lookupState(C owner,
List<String> path)
Finds the state identified by the specified qualified name path, to
resolve an oclIsInState() operation.
|
boolean |
notOK(Option<ProblemHandler.Severity> option)
Queries whether I have a non-OK setting for the specified problem option.
|
void |
setBodyCondition(O operation,
CT constraint)
Associates an operation with an body condition constraint.
|
void |
setDeriveConstraint(P property,
CT constraint)
Associates a property with an derived-value constraint.
|
void |
setInitConstraint(P property,
CT constraint)
Associates a property with an initial-value constraint.
|
void |
setInternalParent(Environment.Internal<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent)
Assigns me a parent environment after construction.
|
void |
setSelfVariable(Variable<C,PM> var)
Sets the "self" variable that is the implicit source of any property,
operation, or association class call.
|
C |
tryLookupAssociationClassReference(C owner,
String name)
This default implementation simply delegates to the
Environment.lookupAssociationClassReference(Object, String) method. |
C |
tryLookupClassifier(List<String> names)
This default implementation simply delegates to the
Environment.lookupClassifier(List) method. |
O |
tryLookupOperation(C owner,
String name,
List<? extends TypedElement<C>> args)
This default implementation simply delegates to the
Environment.lookupOperation(Object, String, List) method. |
PK |
tryLookupPackage(List<String> names)
This default implementation simply delegates to the
Environment.lookupPackage(List) method. |
P |
tryLookupProperty(C owner,
String name)
This default implementation simply delegates to the
Environment.lookupProperty(Object, String) method. |
C |
tryLookupSignal(C owner,
String name,
List<? extends TypedElement<C>> args)
This default implementation simply delegates to the
Environment.lookupSignal(Object, String, List) method. |
analyzerError, analyzerError, analyzerError, analyzerWarning, clearOptions, getASTMapping, getASTNodeToCSTNodeMap, getFormatter, getOptions, getParser, getProblemHandler, getValue, initASTMapping, initASTMapping, isEnabled, lexerError, parserError, problem, putOptions, removeOption, removeOptions, setASTNodeToCSTNodeMap, setOption, setParser, setProblemHandler, utilityError, validatorError
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
analyzerError, analyzerError, analyzerError, analyzerWarning, getASTMapping, getFormatter, getParser, getProblemHandler, initASTMapping, lexerError, parserError, problem, setParser, setProblemHandler, utilityError, validatorError
clearOptions, getOptions, getValue, isEnabled, putOptions, removeOption, removeOptions, setOption
defineAttribute, defineOperation, getDefinition, getFactory, getOCLFactory, getOCLStandardLibrary, getStates, getTypeResolver, getUMLReflection, isInPostcondition, lookupClassifier, lookupPackage, setParent, undefine
public Environment.Internal<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> getInternalParent()
Environment.Internal
@Deprecated public AbstractEnvironment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> getParent()
getInternalParent()
method, instead.Environment
public void setInternalParent(Environment.Internal<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> parent)
null
if I previously had one.public PK getContextPackage()
Environment
getContextPackage
in interface Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
Environment.getContextClassifier()
public C getContextClassifier()
Environment
public O getContextOperation()
Environment
public P getContextProperty()
Environment
public boolean isEmpty()
Environment
public Collection<Variable<C,PM>> getVariables()
Environment
Variable
s registered explicitly in me and any
parents that I may have. This does not include implicit variables or
variables from parent environments that are shadowed by variables in
the nested scope.public boolean addElement(String name, Variable<C,PM> elem, boolean isExplicit)
Environment
addElement
in interface Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
name
- the name of the variable, or null
elem
- a variable declarationisExplicit
- whether this is an explicitly declared variabletrue
if the variable was successfully added because
it wasn't already declared locally in this environment;
false
, otherwisepublic void deleteElement(String name)
Environment
public void setSelfVariable(Variable<C,PM> var)
Environment
public Variable<C,PM> getSelfVariable()
Environment
public void addHelperProperty(C owner, P property)
Environment.Internal
Environment.defineAttribute(C, org.eclipse.ocl.expressions.Variable<C, PM>, CT)
method).public List<P> getAdditionalAttributes(C classifier)
Environment
public void addHelperOperation(C owner, O operation)
Environment.Internal
Environment.defineOperation(C, java.lang.String, C, java.util.List<org.eclipse.ocl.expressions.Variable<C, PM>>, CT)
method).public List<O> getAdditionalOperations(C classifier)
Environment
public void setInitConstraint(P property, CT constraint)
Environment
public CT getInitConstraint(P property)
Environment
public void setDeriveConstraint(P property, CT constraint)
Environment
public CT getDeriveConstraint(P property)
Environment
public void setBodyCondition(O operation, CT constraint)
Environment
public CT getBodyCondition(O operation)
Environment
public Variable<C,PM> lookupLocal(String name)
Environment
public Variable<C,PM> lookup(String name)
Environment
public O lookupOperation(C owner, String name, List<? extends TypedElement<C>> args)
Environment
lookupOperation
in interface Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
owner
- the owner type of the called operation, or null
to find an implicit owner type (in iteration expressions)name
- the name of the called operationargs
- the arguments (expressions or variables) to be matched against
the parameter signature of the operationnull
if not foundpublic P lookupProperty(C owner, String name)
Environment
lookupProperty
in interface Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
owner
- the owner of the property that we are looking for, or
null
to find an implicit owner type (in iteration
expressions)name
- the property namenull
if it could not be foundpublic C lookupAssociationClassReference(C owner, String name)
Environment
lookupAssociationClassReference
in interface Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
owner
- the referencing class to search, or
null
to find an implicit owner type (in iteration
expressions)name
- the association class name (with an initial lower case as
per the OCL convention)null
if the specified owner
is not at the
end of an association with this particular namepublic C lookupSignal(C owner, String name, List<? extends TypedElement<C>> args)
Environment
lookupSignal
in interface Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
owner
- the owner type of the signal receptionname
- the name of the signalargs
- the arguments (expressions or variables) matching the
properties of the signal (parameters of the reception feature)null
if not foundpublic S lookupState(C owner, List<String> path) throws LookupException
Environment
lookupState
in interface Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
owner
- the type on which the oclIsInState() operation is
invokedpath
- the state name to seeknull
if not foundLookupException
- in the case that this path is
ambiguous; i.e., that it does not qualify a state reference with
the state machine name to select between same-named states in
different state machinespublic Variable<C,PM> lookupImplicitSourceForOperation(String name, List<? extends TypedElement<C>> args)
Environment
lookupImplicitSourceForOperation
in interface Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
name
- the operation nameargs
- the list of arguments (expressions or variables) to match
against the operation parametersnull
if no appropriate
variable can be found whose type defines a property of this namepublic Variable<C,PM> lookupImplicitSourceForProperty(String name)
Environment
public Variable<C,PM> lookupImplicitSourceForAssociationClass(String name)
Environment
public Variable<C,PM> lookupImplicitSourceForSignal(String name, List<? extends TypedElement<C>> args)
Environment
lookupImplicitSourceForSignal
in interface Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
name
- the signal nameargs
- the list of arguments (expressions or variables) to match
against the signal reception parametersnull
if no appropriate
variable can be found whose type defines a property of this namepublic Variable<C,PM> lookupImplicitSourceForState(List<String> path) throws LookupException
Environment
lookupImplicitSourceForState
in interface Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
path
- the state name to seeknull
if not foundLookupException
- in the case that this path is
ambiguous; i.e., that it does not qualify a state reference with
the state machine name to select between same-named states in
different state machinespublic C tryLookupAssociationClassReference(C owner, String name) throws LookupException
Environment.lookupAssociationClassReference(Object, String)
method.tryLookupAssociationClassReference
in interface Environment.Lookup<PK,C,O,P>
owner
- the referencing class to search, or
null
to find an implicit owner type (in iteration
expressions)name
- the association class name (with an initial lower case as
per the OCL convention)null
if the specified owner
is not at the
end of an association with this particular nameLookupException
- if lookup fails due to an error such as an ambiguitypublic C tryLookupClassifier(List<String> names) throws LookupException
Environment.lookupClassifier(List)
method.tryLookupClassifier
in interface Environment.Lookup<PK,C,O,P>
names
- the qualified namenull
if not foundLookupException
- if lookup fails due to an error such as an ambiguitypublic O tryLookupOperation(C owner, String name, List<? extends TypedElement<C>> args) throws LookupException
Environment.lookupOperation(Object, String, List)
method.tryLookupOperation
in interface Environment.Lookup<PK,C,O,P>
owner
- the owner type of the called operation, or null
to find an implicit owner type (in iteration expressions)name
- the name of the called operationargs
- the arguments (expressions or variables) to be matched against
the parameter signature of the operationnull
if not foundLookupException
- if lookup fails due to an error such as an ambiguitypublic C tryLookupSignal(C owner, String name, List<? extends TypedElement<C>> args) throws LookupException
Environment.lookupSignal(Object, String, List)
method.tryLookupSignal
in interface Environment.Lookup<PK,C,O,P>
owner
- the owner type of the signal receptionname
- the name of the signalargs
- the arguments (expressions or variables) matching the
properties of the signal (parameters of the reception feature)null
if not foundLookupException
- if lookup fails due to an error such as an ambiguitypublic PK tryLookupPackage(List<String> names) throws LookupException
Environment.lookupPackage(List)
method.tryLookupPackage
in interface Environment.Lookup<PK,C,O,P>
names
- the qualified namenull
if not foundLookupException
- if lookup fails due to an error such as an ambiguitypublic P tryLookupProperty(C owner, String name) throws LookupException
Environment.lookupProperty(Object, String)
method.tryLookupProperty
in interface Environment.Lookup<PK,C,O,P>
owner
- the owner of the property that we are looking for, or
null
to find an implicit owner type (in iteration
expressions)name
- the property namenull
if it could not be foundLookupException
- if lookup fails due to an error such as an ambiguitypublic boolean notOK(Option<ProblemHandler.Severity> option)
option
- the problem optionProblemHandler.Severity.OK
public void dispose()
AbstractTypeResolver
and I am the root environment (which owns the resolver).public <T> T getAdapter(Class<T> adapterType)
AbstractTypeResolver
implements TypeChecker
,
AbstractEnvironment will try to adapt TypeChecker
, via its
TypeResolver
.getAdapter
in interface Adaptable
getAdapter
in class AbstractBasicEnvironment
T
- the requested adapter interfaceadapterType
- the requested adapter interfacenull
if this environment does not adapt to itAbstractBasicEnvironment.getAdapter(java.lang.Class)
Copyright © 2005, 2018 IBM Corporation and others. All Rights Reserved.