public abstract class AbstractEnvironment extends AbstractBasicEnvironment<Environment> implements Environment
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.
| Modifier and Type | Class and Description |
|---|---|
protected class |
AbstractEnvironment.VariableEntry
Wrapper for OCL variable declarations that additionally tracks whether
they are explicit or implicit variables.
|
Environment.RegistryparentOCL_NAMESPACE_URI, RESULT_VARIABLE_NAME, SELF_VARIABLE_NAME| Modifier | Constructor and Description |
|---|---|
protected |
AbstractEnvironment()
Initializes me without a parent environment.
|
protected |
AbstractEnvironment(Environment parent)
Initializes me with the specified parent environment.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addElement(java.lang.String name,
Variable elem,
boolean isExplicit)
Adds a variable declaration to the environment.
|
void |
dispose()
I dispose my type resolver, if it is an
AbstractTypeResolver
and I am the root environment (which owns the resolver). |
Type |
getContextClassifier()
Obtains the context classifier of this environment.
|
Operation |
getContextOperation()
Obtains the context operation of this environment, if it is an operation
context.
|
Package |
getContextPackage()
Initializes me with the specified parent environment, which should be
of the same type as me.
|
Property |
getContextProperty()
Obtains the context property of this environment, if it is a property
context.
|
Variable |
getSelfVariable()
Gets the self variable, looking it up in a parent environment if necessary.
|
protected void |
setContextOperation(Operation contextOperation)
Assigns my context operation.
|
protected void |
setContextPackage(Package contextPackage)
Assigns my context package.
|
protected void |
setContextProperty(Property contextProperty)
Assigns my context property.
|
void |
setSelfVariable(Variable var)
Sets the "self" variable that is the implicit source of any property,
operation, or association class call.
|
basicGetOptions, clearOptions, getAdapter, getOptions, getParent, getValue, isEnabled, notOK, putOptions, removeOption, removeOptions, setOption, setParentclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetDefinition, getFactory, getMetaModelManager, getOCLFactory, getOCLStandardLibrary, getParent, getStatesgetAdapterclearOptions, getOptions, getValue, isEnabled, putOptions, removeOption, removeOptions, setOptionprotected AbstractEnvironment()
protected AbstractEnvironment(Environment parent)
parent - an environment (or null)public boolean addElement(@NonNull
java.lang.String name,
@NonNull
Variable elem,
boolean isExplicit)
EnvironmentaddElement in interface Environmentname - the name of the variable, or nullelem - 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 dispose()
AbstractTypeResolver
and I am the root environment (which owns the resolver).dispose in interface Environment@Nullable public Package getContextPackage()
getContextPackage in interface Environmentparent - an environment of the same type as me (or null)Environment.getContextClassifier()@Nullable public Type getContextClassifier()
EnvironmentgetContextClassifier in interface Environment@Nullable public Operation getContextOperation()
EnvironmentgetContextOperation in interface Environmentnull if this is not an
operation environment@Nullable public Property getContextProperty()
EnvironmentgetContextProperty in interface Environmentnull if this is not a
property environment@Nullable public Variable getSelfVariable()
EnvironmentgetSelfVariable in interface Environmentnull if none (which should
only be the case in a root environment having only a package context,
if even that)protected void setContextOperation(@Nullable
Operation contextOperation)
contextOperation - my context operationprotected void setContextPackage(@Nullable
Package contextPackage)
contextPackage - my new context packageprotected void setContextProperty(@Nullable
Property contextProperty)
contextProperty - my context propertypublic void setSelfVariable(@NonNull
Variable var)
EnvironmentsetSelfVariable in interface Environmentvar - the "self" variable