PK
- is substituted by the metaclass representing the metamodel's
analogue for the UML 2.x PackageC
- corresponds to the UML Classifier metaclassO
- corresponds to the UML Operation metaclassP
- corresponds to the UML Property metaclassEL
- corresponds to the UML EnumerationLiteral metaclass
(Enumerations are simply represented as classifiers)PM
- corresponds to the UML Parameter metaclassS
- corresponds to the UML State metaclass (for metamodels
that describe state machines)COA
- corresponds to the UML CallOperationAction metaclass
(used in message expressions)SSA
- corresponds to the UML SendSignalAction metaclass
(used in message expressions)CT
- corresponds to the UML Constraint metaclassCLS
- corresponds to the UML Class metaclassE
- corresponds to the UML Element metaclasspublic interface Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
The generic type parameters of this interface represent the UML concepts that
the OCL parser and evaluation engine require. A binding for a particular
metamodel (e.g., Ecore or UML) is implemented as a concrete Environment
with appropriate metaclasses substituting for these type parameters.
This interface is not intended to be implemented "directly" by
providers of metamodel bindings.
It is highly recommended to extend the AbstractEnvironment
class,
instead.
Since 1.2, the default abstract implementation of this interface
(AbstractEnvironment
) implements the Adaptable
protocol to
provide dynamic interface adapters. Use the
OCLUtil.getAdapter(Environment, Class)
method to obtain
adapters for any environment instance.
AbstractEnvironment
,
EnvironmentFactory
Modifier and Type | Interface and Description |
---|---|
static interface |
Environment.Internal<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
An interface that merges the
Environment and
BasicEnvironment interfaces that define the
behaviour realised in abstract form by AbstractEnvironment . |
static interface |
Environment.Lookup<PK,C,O,P>
Optional adapter interface for look-up methods that throw
LookupException s on abnormal failures (usually ambiguous names). |
static interface |
Environment.Registry
A registry of environments.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
OCL_NAMESPACE_URI
Namespace URI of the OCL core metamodel, used for example as the
source of certain Ecore annotations.
|
static java.lang.String |
RESULT_VARIABLE_NAME
The name of the operation result variable 'result'.
|
static java.lang.String |
SELF_VARIABLE_NAME
The name of the context variable 'self'.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addElement(java.lang.String name,
Variable<C,PM> elem,
boolean explicit)
Adds a variable declaration to the environment.
|
P |
defineAttribute(C owner,
Variable<C,PM> variable,
CT constraint)
In processing an additional attribute definition, constructs the
property and associates it with its definition constraint.
|
O |
defineOperation(C owner,
java.lang.String name,
C type,
java.util.List<Variable<C,PM>> params,
CT constraint)
In processing an additional operation definition, constructs the
operation and associates it with its definition constraint.
|
void |
deleteElement(java.lang.String name)
Removes a variable when it goes out of scope.
|
java.util.List<P> |
getAdditionalAttributes(C classifier)
Obtains the additional attributes defined in this environment in the
context of the specified classifier.
|
java.util.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 |
getDefinition(java.lang.Object feature)
Obtains the definition constraint of the specified feature, if it is an
additional attribute or operation defined via an OCL constraint.
|
CT |
getDeriveConstraint(P property)
Obtains a property's derived-value constraint.
|
EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> |
getFactory()
Obtains the factory that created me, or an appropriate default factory
if I was not created using a factory.
|
CT |
getInitConstraint(P property)
Obtains a property's with an initial-value constraint, if any.
|
OCLFactory |
getOCLFactory()
Obtains a factory for the creation of types that are parameterized
by model elements.
|
OCLStandardLibrary<C> |
getOCLStandardLibrary()
Obtains the collection of core types representing the OCL Standard
Library.
|
Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> |
getParent()
Obtains my parent environment, if I have one.
|
Variable<C,PM> |
getSelfVariable()
Gets the self variable, looking it up in a parent environment if necessary.
|
java.util.List<S> |
getStates(C owner,
java.util.List<java.lang.String> pathPrefix)
Retrieves a list of all possible states of the specified
owner
whose paths are prefixed by the specified partial name. |
TypeResolver<C,O,P> |
getTypeResolver()
Obtains a type resolver to be used to create (and cache) concrete bindings
for the generic OCL types, based on the user model types provided by this
environment.
|
UMLReflection<PK,C,O,P,EL,PM,S,COA,SSA,CT> |
getUMLReflection()
Obtains a utility for for reflection on the UML metaclasses that are
used by the OCL abstract syntax.
|
java.util.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.
|
boolean |
isInPostcondition(OCLExpression<C> exp)
Checks whether the specified OCL expression is in an operation
postcondition constraint.
|
Variable<C,PM> |
lookup(java.lang.String name)
Obtains the Variable bound to a variable name.
|
C |
lookupAssociationClassReference(C owner,
java.lang.String name)
Finds a reference in the specified class to the named association class.
|
C |
lookupClassifier(java.util.List<java.lang.String> names)
Finds the classifier identified by the specified sequence of names
(a qualified name).
|
Variable<C,PM> |
lookupImplicitSourceForAssociationClass(java.lang.String name)
Return an implicit variable that references the
named association class.
|
Variable<C,PM> |
lookupImplicitSourceForOperation(java.lang.String name,
java.util.List<? extends TypedElement<C>> args)
Return an implicit variable declaration that defines the specified
operation signature.
|
Variable<C,PM> |
lookupImplicitSourceForProperty(java.lang.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(java.lang.String name,
java.util.List<? extends TypedElement<C>> args)
Return an implicit variable declaration that defines the specified
signal reception signature.
|
Variable<C,PM> |
lookupImplicitSourceForState(java.util.List<java.lang.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(java.lang.String name)
Obtains the Variable bound to a local variable name.
|
O |
lookupOperation(C owner,
java.lang.String name,
java.util.List<? extends TypedElement<C>> args)
Find an operation in the specified class.
|
PK |
lookupPackage(java.util.List<java.lang.String> names)
Finds the package identified by the specified sequence of names
(a qualified name).
|
P |
lookupProperty(C owner,
java.lang.String name)
Finds a property defined or inherited by the specified classifier.
|
C |
lookupSignal(C owner,
java.lang.String name,
java.util.List<? extends TypedElement<C>> args)
Finds a received signal in the specified classifier.
|
S |
lookupState(C owner,
java.util.List<java.lang.String> path)
Finds the state identified by the specified qualified name path, to
resolve an oclIsInState() operation.
|
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 |
setParent(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> env)
Sets my parent environment.
|
void |
setSelfVariable(Variable<C,PM> var)
Sets the "self" variable that is the implicit source of any property,
operation, or association class call.
|
void |
undefine(java.lang.Object feature)
Removes the definition of an additional operation or property.
|
static final java.lang.String OCL_NAMESPACE_URI
static final java.lang.String SELF_VARIABLE_NAME
static final java.lang.String RESULT_VARIABLE_NAME
EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> getFactory()
EnvironmentFactory.createEnvironment(Environment)
Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> getParent()
null
if I am a root environmentvoid setParent(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> env)
null
if it was not already null
.env
- my new parent environmentPK getContextPackage()
getContextClassifier()
C getContextClassifier()
O getContextOperation()
null
if this is not an
operation environmentP getContextProperty()
null
if this is not a
property environmentOCLStandardLibrary<C> getOCLStandardLibrary()
EnvironmentFactory
.TypeResolver<C,O,P> getTypeResolver()
boolean isEmpty()
true
if no local variables are defined;
false
, otherwiseVariable<C,PM> lookupLocal(java.lang.String name)
name
- a variable name to look upnull
if not found in
this particular environmentVariable<C,PM> lookup(java.lang.String name)
name
- a variable name to look upnull
if not found in
this particular environmentPK lookupPackage(java.util.List<java.lang.String> names)
names
- the qualified namenull
if not foundC lookupClassifier(java.util.List<java.lang.String> names)
names
- the qualified namenull
if not foundO lookupOperation(C owner, java.lang.String name, java.util.List<? extends TypedElement<C>> args)
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 foundP lookupProperty(C owner, java.lang.String name)
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 foundC lookupAssociationClassReference(C owner, java.lang.String name)
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 nameS lookupState(C owner, java.util.List<java.lang.String> path) throws LookupException, SemanticException
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 machinesSemanticException
- which usually would actually be a
LookupException (see above)java.util.List<S> getStates(C owner, java.util.List<java.lang.String> pathPrefix)
owner
whose paths are prefixed by the specified partial name. If the
owner is null
, then the target of the oclIsInState()
operation call is implicit and must be looked up in the usual way for
implicit operation call targets. This method is used for content-assist.owner
- the classifier for which states are being sought. Can be
null
in the case of an oclIsInState() call on an
implicit targetpathPrefix
- partial path name of the states being sought. This
can be empty to find the first level of state namesC lookupSignal(C owner, java.lang.String name, java.util.List<? extends TypedElement<C>> args)
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 foundboolean isInPostcondition(OCLExpression<C> exp)
exp
- an OCL expressiontrue
if it is in a postcondition constraint;
false
, otherwise (including case of no constraint at all)boolean addElement(java.lang.String name, Variable<C,PM> elem, boolean explicit)
name
- the name of the variable, or null
elem
- a variable declarationexplicit
- whether this is an explicitly declared variabletrue
if the variable was successfully added because
it wasn't already declared locally in this environment;
false
, otherwisevoid deleteElement(java.lang.String name)
name
- the name of the variable to deletejava.util.Collection<Variable<C,PM>> getVariables()
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.void setSelfVariable(Variable<C,PM> var)
var
- the "self" variableVariable<C,PM> getSelfVariable()
null
if none (which should
only be the case in a root environment having only a package context,
if even that)Variable<C,PM> lookupImplicitSourceForProperty(java.lang.String name)
name
- the property namenull
if no appropriate
variable can be found whose type defines a property of this nameVariable<C,PM> lookupImplicitSourceForAssociationClass(java.lang.String name)
name
- the association class name to seeknull
if no appropriate
variable can be found whose type defines a property of this nameVariable<C,PM> lookupImplicitSourceForOperation(java.lang.String name, java.util.List<? extends TypedElement<C>> args)
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 nameVariable<C,PM> lookupImplicitSourceForSignal(java.lang.String name, java.util.List<? extends TypedElement<C>> args)
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 nameVariable<C,PM> lookupImplicitSourceForState(java.util.List<java.lang.String> path) throws LookupException, SemanticException
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 machinesSemanticException
- which usually would actually be a
LookupException (see above)P defineAttribute(C owner, Variable<C,PM> variable, CT constraint)
owner
- the context classifier of the property definition constraintvariable
- the name and type of the property (conveniently
encapsulated in a variable)constraint
- the definition constraintjava.util.List<P> getAdditionalAttributes(C classifier)
classifier
- a classifierO defineOperation(C owner, java.lang.String name, C type, java.util.List<Variable<C,PM>> params, CT constraint)
owner
- the context classifier of the property definition constraintname
- the operation nameparams
- the names and types of the parameters, if any (conveniently
encapsulated in variables)constraint
- the definition constraintjava.util.List<O> getAdditionalOperations(C classifier)
classifier
- a classifierCT getDefinition(java.lang.Object feature)
feature
- a property or operationnull
if this feature is not defined by OCLvoid undefine(java.lang.Object feature)
feature
- an additional property or operationjava.lang.IllegalArgumentException
- if the specified feature is
not an additional feature defined via an OCL constraintvoid setInitConstraint(P property, CT constraint)
property
- an attributeconstraint
- its initial-value constraintCT getInitConstraint(P property)
property
- an attributenull
if nonevoid setDeriveConstraint(P property, CT constraint)
property
- an attributeconstraint
- its derived-value constraintCT getDeriveConstraint(P property)
property
- an attributevoid setBodyCondition(O operation, CT constraint)
operation
- an operationconstraint
- its body condition constraintCT getBodyCondition(O operation)
operation
- an operationOCLFactory getOCLFactory()