public class EcoreEnvironment extends AbstractEnvironment<EPackage,EClassifier,EOperation,EStructuralFeature,EEnumLiteral,EParameter,EObject,CallOperationAction,SendSignalAction,Constraint,EClass,EObject> implements EnvironmentWithHiddenOpposites
Environment
for parsing OCL expressions on
Ecore models. The EcoreEnvironment
uses a client-supplied
package registry (or the global registry) to look up EPackage
s
by qualified name.Environment.Internal<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>, Environment.Lookup<PK,C,O,P>, Environment.Registry
Modifier and Type | Field and Description |
---|---|
static String |
OCL_STANDARD_LIBRARY_NS_URI
The namespace URI of the Ecore representation of the OCL Standard Library.
|
OCL_NAMESPACE_URI, RESULT_VARIABLE_NAME, SELF_VARIABLE_NAME
Modifier and Type | Method and Description |
---|---|
EStructuralFeature |
defineAttribute(EClassifier owner,
Variable<EClassifier,EParameter> variable,
Constraint constraint)
In processing an additional attribute definition, constructs the
property and associates it with its definition constraint.
|
EOperation |
defineOperation(EClassifier owner,
String name,
EClassifier type,
List<Variable<EClassifier,EParameter>> params,
Constraint constraint)
In processing an additional operation definition, constructs the
operation and associates it with its definition constraint.
|
static EPackage |
findPackage(List<String> packageNames)
Looks in the EMF registry for a package with the specified qualified
package name.
|
static EPackage |
findPackage(List<String> packageNames,
EPackage.Registry registry)
Looks in the given registry for a package with the specified qualified
package name.
|
Constraint |
getDefinition(Object feature)
Obtains the definition constraint of the specified feature, if it is an
additional attribute or operation defined via an OCL constraint.
|
EnvironmentFactory<EPackage,EClassifier,EOperation,EStructuralFeature,EEnumLiteral,EParameter,EObject,CallOperationAction,SendSignalAction,Constraint,EClass,EObject> |
getFactory()
Obtains the factory that created me, or an appropriate default factory
if I was not created using a factory.
|
Map<String,EReference> |
getHiddenOppositeProperties(EClassifier classifier)
Finds all
EReference s whose type
is classifier or any of classifier 's super
types and that own an annotation with source
EMOFExtendedMetaData#EMOF_PACKAGE_NS_URI_2_0 containing a detail
entry with key OppositeEndFinder.PROPERTY_OPPOSITE_ROLE_NAME_KEY . |
OCLFactory |
getOCLFactory()
Obtains a factory for the creation of types that are parameterized
by model elements.
|
OCLStandardLibrary<EClassifier> |
getOCLStandardLibrary()
Obtains the collection of core types representing the OCL Standard
Library.
|
OppositeEndFinder |
getOppositeEndFinder() |
EClassifier |
getOppositePropertyType(EClassifier owner,
EReference property)
Determines a property's (hidden) opposite's type, assuming that there is not real opposite
but that the opposite's type implicitly defaults to the property's owning class.
|
List<EObject> |
getStates(EClassifier owner,
List<String> pathPrefix)
Obtains the states matching the specified path prefix in the owner type
by trying the
collectStates(EClassifier, java.util.List<java.lang.String>, java.util.List<EObject>) method on it and, recursively, its
supertypes to find all matches. |
TypeResolver<EClassifier,EOperation,EStructuralFeature> |
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<EPackage,EClassifier,EOperation,EStructuralFeature,EEnumLiteral,EParameter,EObject,CallOperationAction,SendSignalAction,Constraint> |
getUMLReflection()
Obtains a utility for for reflection on the UML metaclasses that are
used by the OCL abstract syntax.
|
boolean |
isInPostcondition(OCLExpression<EClassifier> exp)
Checks whether the specified OCL expression is in an operation
postcondition constraint.
|
EClassifier |
lookupClassifier(List<String> names)
Finds the classifier identified by the specified sequence of names
(a qualified name).
|
Variable<EClassifier,EParameter> |
lookupImplicitSourceForOppositeProperty(String name)
Return the most appropriate matching variable to use as the implicit
source of a call to the specified property.
|
EReference |
lookupOppositeProperty(EClassifier owner,
String name)
Looks up a non-navigable association end on behalf of
the specified
owner classifier (which is at that end). |
EPackage |
lookupPackage(List<String> path)
Finds the package identified by the specified sequence of names
(a qualified name).
|
void |
setParent(Environment<EPackage,EClassifier,EOperation,EStructuralFeature,EEnumLiteral,EParameter,EObject,CallOperationAction,SendSignalAction,Constraint,EClass,EObject> env)
Sets my parent environment.
|
EReference |
tryLookupOppositeProperty(EClassifier owner,
String name)
This default implementation simply delegates to the
lookupOppositeProperty(EClassifier, String) method. |
EStructuralFeature |
tryLookupProperty(EClassifier owner,
String name)
This default implementation simply delegates to the
Environment.lookupProperty(Object, String) method. |
void |
undefine(Object feature)
Removes the definition of an additional operation or property.
|
addElement, addHelperOperation, addHelperProperty, deleteElement, dispose, getAdapter, getAdditionalAttributes, getAdditionalOperations, getBodyCondition, getContextClassifier, getContextOperation, getContextPackage, getContextProperty, getDeriveConstraint, getInitConstraint, getInternalParent, getParent, getSelfVariable, getVariables, isEmpty, lookup, lookupAssociationClassReference, lookupImplicitSourceForAssociationClass, lookupImplicitSourceForOperation, lookupImplicitSourceForProperty, lookupImplicitSourceForSignal, lookupImplicitSourceForState, lookupLocal, lookupOperation, lookupProperty, lookupSignal, lookupState, notOK, setBodyCondition, setDeriveConstraint, setInitConstraint, setInternalParent, setSelfVariable, tryLookupAssociationClassReference, tryLookupClassifier, tryLookupOperation, tryLookupPackage, tryLookupSignal
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
addElement, deleteElement, getAdditionalAttributes, getAdditionalOperations, getBodyCondition, getContextClassifier, getContextOperation, getContextPackage, getContextProperty, getDeriveConstraint, getInitConstraint, getParent, getSelfVariable, getVariables, isEmpty, lookup, lookupAssociationClassReference, lookupImplicitSourceForAssociationClass, lookupImplicitSourceForOperation, lookupImplicitSourceForProperty, lookupImplicitSourceForSignal, lookupImplicitSourceForState, lookupLocal, lookupOperation, lookupProperty, lookupSignal, lookupState, setBodyCondition, setDeriveConstraint, setInitConstraint, setSelfVariable
analyzerError, analyzerError, analyzerError, analyzerWarning, getASTMapping, getFormatter, getParser, getProblemHandler, initASTMapping, lexerError, parserError, problem, setParser, setProblemHandler, utilityError, validatorError
clearOptions, getOptions, getValue, isEnabled, putOptions, removeOption, removeOptions, setOption
public static final String OCL_STANDARD_LIBRARY_NS_URI
public EnvironmentFactory<EPackage,EClassifier,EOperation,EStructuralFeature,EEnumLiteral,EParameter,EObject,CallOperationAction,SendSignalAction,Constraint,EClass,EObject> getFactory()
Environment
getFactory
in interface Environment<EPackage,EClassifier,EOperation,EStructuralFeature,EEnumLiteral,EParameter,EObject,CallOperationAction,SendSignalAction,Constraint,EClass,EObject>
EnvironmentFactory.createEnvironment(Environment)
public void setParent(Environment<EPackage,EClassifier,EOperation,EStructuralFeature,EEnumLiteral,EParameter,EObject,CallOperationAction,SendSignalAction,Constraint,EClass,EObject> env)
Environment
null
if it was not already null
.setParent
in interface Environment<EPackage,EClassifier,EOperation,EStructuralFeature,EEnumLiteral,EParameter,EObject,CallOperationAction,SendSignalAction,Constraint,EClass,EObject>
env
- my new parent environmentpublic OCLStandardLibrary<EClassifier> getOCLStandardLibrary()
Environment
EnvironmentFactory
.getOCLStandardLibrary
in interface Environment<EPackage,EClassifier,EOperation,EStructuralFeature,EEnumLiteral,EParameter,EObject,CallOperationAction,SendSignalAction,Constraint,EClass,EObject>
public TypeResolver<EClassifier,EOperation,EStructuralFeature> getTypeResolver()
Environment
getTypeResolver
in interface Environment<EPackage,EClassifier,EOperation,EStructuralFeature,EEnumLiteral,EParameter,EObject,CallOperationAction,SendSignalAction,Constraint,EClass,EObject>
public OCLFactory getOCLFactory()
Environment
getOCLFactory
in interface Environment<EPackage,EClassifier,EOperation,EStructuralFeature,EEnumLiteral,EParameter,EObject,CallOperationAction,SendSignalAction,Constraint,EClass,EObject>
public UMLReflection<EPackage,EClassifier,EOperation,EStructuralFeature,EEnumLiteral,EParameter,EObject,CallOperationAction,SendSignalAction,Constraint> getUMLReflection()
Environment
getUMLReflection
in interface Environment<EPackage,EClassifier,EOperation,EStructuralFeature,EEnumLiteral,EParameter,EObject,CallOperationAction,SendSignalAction,Constraint,EClass,EObject>
public EPackage lookupPackage(List<String> path)
Implements the inherited specification by looking up the qualified name in my package registry.
lookupPackage
in interface Environment<EPackage,EClassifier,EOperation,EStructuralFeature,EEnumLiteral,EParameter,EObject,CallOperationAction,SendSignalAction,Constraint,EClass,EObject>
path
- the qualified namenull
if not foundpublic EClassifier lookupClassifier(List<String> names)
Environment
lookupClassifier
in interface Environment<EPackage,EClassifier,EOperation,EStructuralFeature,EEnumLiteral,EParameter,EObject,CallOperationAction,SendSignalAction,Constraint,EClass,EObject>
names
- the qualified namenull
if not foundpublic List<EObject> getStates(EClassifier owner, List<String> pathPrefix)
collectStates(EClassifier, java.util.List<java.lang.String>, java.util.List<EObject>)
method on it and, recursively, its
supertypes to find all matches. For implicit (null
) owners,
looks up the innermost-scoped variable as the implicit source and tries
again on this variable's type.
To extend this implementation, override the
collectStates(EClassifier, java.util.List<java.lang.String>, java.util.List<EObject>)
method.
getStates
in interface Environment<EPackage,EClassifier,EOperation,EStructuralFeature,EEnumLiteral,EParameter,EObject,CallOperationAction,SendSignalAction,Constraint,EClass,EObject>
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 namespublic EStructuralFeature defineAttribute(EClassifier owner, Variable<EClassifier,EParameter> variable, Constraint constraint)
Environment
defineAttribute
in interface Environment<EPackage,EClassifier,EOperation,EStructuralFeature,EEnumLiteral,EParameter,EObject,CallOperationAction,SendSignalAction,Constraint,EClass,EObject>
owner
- the context classifier of the property definition constraintvariable
- the name and type of the property (conveniently
encapsulated in a variable)constraint
- the definition constraintpublic EOperation defineOperation(EClassifier owner, String name, EClassifier type, List<Variable<EClassifier,EParameter>> params, Constraint constraint)
Environment
defineOperation
in interface Environment<EPackage,EClassifier,EOperation,EStructuralFeature,EEnumLiteral,EParameter,EObject,CallOperationAction,SendSignalAction,Constraint,EClass,EObject>
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 constraintpublic void undefine(Object feature)
Environment
undefine
in interface Environment<EPackage,EClassifier,EOperation,EStructuralFeature,EEnumLiteral,EParameter,EObject,CallOperationAction,SendSignalAction,Constraint,EClass,EObject>
feature
- an additional property or operationpublic Constraint getDefinition(Object feature)
Environment
getDefinition
in interface Environment<EPackage,EClassifier,EOperation,EStructuralFeature,EEnumLiteral,EParameter,EObject,CallOperationAction,SendSignalAction,Constraint,EClass,EObject>
feature
- a property or operationnull
if this feature is not defined by OCLpublic static EPackage findPackage(List<String> packageNames)
packageNames
- the qualified package namenull
if not foundpublic static EPackage findPackage(List<String> packageNames, EPackage.Registry registry)
packageNames
- the qualified package nameregistry
- the EPackage.Registry to look innull
if not foundpublic boolean isInPostcondition(OCLExpression<EClassifier> exp)
Environment
isInPostcondition
in interface Environment<EPackage,EClassifier,EOperation,EStructuralFeature,EEnumLiteral,EParameter,EObject,CallOperationAction,SendSignalAction,Constraint,EClass,EObject>
exp
- an OCL expressiontrue
if it is in a postcondition constraint;
false
, otherwise (including case of no constraint at all)public Variable<EClassifier,EParameter> lookupImplicitSourceForOppositeProperty(String name)
EnvironmentWithHiddenOpposites
lookupImplicitSourceForOppositeProperty
in interface EnvironmentWithHiddenOpposites
name
- the property namenull
if no appropriate
variable can be found whose type defines a property of this namepublic EReference lookupOppositeProperty(EClassifier owner, String name) throws LookupException
owner
classifier (which is at that end).lookupOppositeProperty
in interface EnvironmentWithHiddenOpposites
owner
- a classifier in the context of which the property is usedname
- the end name to look upnull
if it cannot
be foundLookupException
- in case that multiple non-navigable properties
are found that have the same name and the problem option is ERROR
or worsepublic EReference tryLookupOppositeProperty(EClassifier owner, String name) throws LookupException
lookupOppositeProperty(EClassifier, String)
method.LookupException
public EStructuralFeature tryLookupProperty(EClassifier owner, String name) throws LookupException
Environment.lookupProperty(Object, String)
method.tryLookupProperty
in interface Environment.Lookup<EPackage,EClassifier,EOperation,EStructuralFeature>
tryLookupProperty
in class AbstractEnvironment<EPackage,EClassifier,EOperation,EStructuralFeature,EEnumLiteral,EParameter,EObject,CallOperationAction,SendSignalAction,Constraint,EClass,EObject>
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 EClassifier getOppositePropertyType(EClassifier owner, EReference property)
EnvironmentWithHiddenOpposites
getOppositePropertyType
in interface EnvironmentWithHiddenOpposites
public Map<String,EReference> getHiddenOppositeProperties(EClassifier classifier)
EnvironmentWithHiddenOpposites
EReference
s whose type
is classifier
or any of classifier
's super
types and that own an annotation
with source
EMOFExtendedMetaData#EMOF_PACKAGE_NS_URI_2_0
containing a detail
entry with key OppositeEndFinder.PROPERTY_OPPOSITE_ROLE_NAME_KEY
.
The value of the annotation detail is entered into the resulting map as a
key, the EReference
on which the annotation was found is entered
into the result map as the corresponding value.
getHiddenOppositeProperties
in interface EnvironmentWithHiddenOpposites
null
map of all "hidden references" accessible from
classifier
together with their corresponding forward
referencespublic OppositeEndFinder getOppositeEndFinder()
Copyright © 2005, 2018 IBM Corporation and others. All Rights Reserved.