|
||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.emf.ocl.parser.EcoreEnvironment
An Environment stores the variables created while evaluating an OCL expression, including self. It also stores the package, if the OCL package statement is used. Methods are provided for querying whether variable, property, operation, and association class reference names belong to the environment.
This environment provides persistence of dynamically-generated types via
its TypeResolver
's resource. The default resolver implementation
uses the most basic resource implementation, which does not support
persistence, so clients requiring persistence should initialize it with their
own resource. Persistence of Variable
s is virtual: the variables
are stored in a resource that reconstructs variables on-the-fly from data
encoded in their URI fragments.
Field Summary |
---|
Fields inherited from interface org.eclipse.emf.ocl.parser.Environment |
---|
ANNOTATION_URI_BODY, ANNOTATION_URI_DEFINE, ANNOTATION_URI_DERIVE, ANNOTATION_URI_INIT |
Constructor Summary | |
---|---|
EcoreEnvironment(Environment parent)
|
|
EcoreEnvironment(org.eclipse.emf.ecore.EPackage pkg)
Create an environment, set the default package from a package statement, and set the package registry to the global package registry. |
|
EcoreEnvironment(org.eclipse.emf.ecore.EPackage pkg,
org.eclipse.emf.ecore.EPackage.Registry reg)
Create an environment, set the default package from a package statement, and set the package registry |
Method Summary | |
---|---|
boolean |
addElement(java.lang.String name,
Variable elem,
boolean exp)
Adds a variable declaration to the environment. |
protected void |
collectStates(org.eclipse.emf.ecore.EClassifier owner,
java.util.List pathPrefix,
java.util.List states)
Implemented by subclasses to find all states in the specified owner type that match the given path name prefix and add them to the accumulator list. |
protected TypeResolver |
createTypeResolver()
Creates a new type resolver for use with this environment. |
void |
deleteElement(java.lang.String name)
Removes a name when it goes out of scope. |
static org.eclipse.emf.ecore.EPackage |
findPackage(java.util.List packageNames)
Looks in the EMF registry for a package with the specified qualified package name. |
static org.eclipse.emf.ecore.EPackage |
findPackage(java.util.List packageNames,
org.eclipse.emf.ecore.EPackage.Registry registry)
Looks in the given registry for a package with the specified qualified package name. |
org.eclipse.emf.ecore.EClass |
getAssociationClass(org.eclipse.emf.ecore.EReference reference)
Obtains the association class that the specified reference represents, as an EClass , if any. |
org.eclipse.emf.ecore.EClassifier |
getContextClassifier()
Obtains the context classifier of this environment. |
org.eclipse.emf.ecore.EOperation |
getContextOperation()
Obtains the context operation of this environment, if it is an operation context. |
org.eclipse.emf.ecore.EStructuralFeature |
getContextProperty()
Obtains the context property of this environment, if it is a property context. |
java.lang.String |
getDescription(org.eclipse.emf.ecore.ENamedElement namedElement)
Default implementation just gets the name of the named element's eClass or, if it is an
ETypedElement , the name of its type. |
EnvironmentFactory |
getFactory()
Obtains the factory that created me, or an appropriate default factory if I was not created using a factory. |
org.eclipse.emf.common.util.EList |
getMemberEnds(org.eclipse.emf.ecore.EClass associationClass)
Obtains the ends of the specified association class as a list of EReference s. |
static org.eclipse.emf.ecore.EClassifier |
getOCLCollectionType(org.eclipse.emf.ecore.EClassifier type,
boolean isOrdered,
boolean isUnique)
Obtains the appropriate OCL collection type for an EClassifier ,
according to the collection's orderedness and uniqueness. |
static org.eclipse.emf.ecore.EClassifier |
getOCLType(org.eclipse.emf.ecore.EClassifier type)
Obtains the appropriate OCL type for an EClassifier , if it
corresponds to an OCL primitive type. |
static org.eclipse.emf.ecore.EClassifier |
getOCLType(org.eclipse.emf.ecore.ETypedElement typedElement)
Obtains the appropriate OCL type for an Ecore typed element, according to its type, multiplicity, orderedness, and uniqueness. |
Environment |
getParent()
get the parent environment |
org.eclipse.emf.common.util.EList |
getQualifiers(org.eclipse.emf.ecore.EStructuralFeature property)
Gets the qualifiers of an association end. |
Variable |
getSelfVariable()
Gets the self variable, looking it up in a parent environment if necessary. |
org.eclipse.emf.common.util.EList |
getSignals(org.eclipse.emf.ecore.EClassifier owner)
By default, return an empty list because Ecore does not support the modeling of signals. |
java.lang.String |
getStateName(org.eclipse.emf.ecore.EObject state)
Ecore does not model states, so this method returns null. |
org.eclipse.emf.common.util.EList |
getStates(org.eclipse.emf.ecore.EClassifier owner,
java.util.List pathPrefix)
Obtains the states matching the specified path prefix in the owner type by trying the EcoreEnvironment.collectStates(org.eclipse.emf.ecore.EClassifier, java.util.List, java.util.List) method on it and, recursively, its
supertypes to find all matches. |
TypeResolver |
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. |
java.util.Collection |
getVariables()
Returns the Variable s registered in me explicitly. |
static java.lang.String |
initialLower(org.eclipse.emf.ecore.ENamedElement elem)
Gets the name of a named elem ent with its initial character
in lower case. |
boolean |
isAssociationClass(org.eclipse.emf.ecore.EClass eclass)
Determines whether the specified eclass is an association
class. |
boolean |
isEmpty()
Is the environment empty? |
boolean |
isQuery(org.eclipse.emf.ecore.EOperation operation)
Determines whether the specified operation is a query
operation. |
Variable |
lookup(java.lang.String name)
returns the VariableDeclaration for a variable Looks in parent environment scope if not found in current scope. |
org.eclipse.emf.ecore.EClass |
lookupAssociationClassReference(org.eclipse.emf.ecore.EClassifier parentClassifier,
java.lang.String name)
Find reference in the specified class to the named association class. |
Variable |
lookupImplicitSourceForAssociationClass(java.lang.String name)
Return the variable declaration in namedElements which references the named association class. |
Variable |
lookupImplicitSourceForOperation(java.lang.String name,
org.eclipse.emf.common.util.EList params)
Return the Variable declaration in namedElements which contains the name as an EOperation. |
Variable |
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 |
lookupLocal(java.lang.String name)
Returns the VariableDeclaration for a variable name. |
org.eclipse.emf.ecore.EOperation |
lookupOperation(org.eclipse.emf.ecore.EClassifier owner,
java.lang.String name,
org.eclipse.emf.common.util.EList args)
Find the operation in the specified class. |
org.eclipse.emf.ecore.EPackage |
lookupPackage(java.util.List path)
Finds the EPackage corresponding to the path: name::... |
org.eclipse.emf.ecore.EClassifier |
lookupPathName(java.util.List names)
Finds the EClassifier corresponding to the path: name::... |
org.eclipse.emf.ecore.EStructuralFeature |
lookupProperty(org.eclipse.emf.ecore.EClassifier owner,
java.lang.String name)
Find a property defined or inherited by the specified classifier. |
org.eclipse.emf.ecore.EClass |
lookupSignal(org.eclipse.emf.ecore.EClassifier owner,
java.lang.String name,
org.eclipse.emf.common.util.EList args)
Find a received signal in the specified classifier. |
void |
setContextOperation(org.eclipse.emf.ecore.EOperation operation)
|
void |
setContextProperty(org.eclipse.emf.ecore.EStructuralFeature property)
|
protected void |
setFactory(EnvironmentFactory factory)
Sets the factory that created me. |
void |
setParent(Environment env)
Set the parent environment |
void |
setSelfVariable(Variable var)
Sets the "self" variable that is the implicit source of any attribute, association end, or operation call. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public EcoreEnvironment(org.eclipse.emf.ecore.EPackage pkg)
pkg
- public EcoreEnvironment(org.eclipse.emf.ecore.EPackage pkg, org.eclipse.emf.ecore.EPackage.Registry reg)
pkg
- reg
- public EcoreEnvironment(Environment parent)
Method Detail |
public static org.eclipse.emf.ecore.EClassifier getOCLType(org.eclipse.emf.ecore.ETypedElement typedElement)
typedElement
- the ECore typed element to get the OCL type for
EcoreEnvironment.getOCLType(EClassifier)
,
EcoreEnvironment.getOCLCollectionType(EClassifier, boolean, boolean)
public static org.eclipse.emf.ecore.EClassifier getOCLType(org.eclipse.emf.ecore.EClassifier type)
EClassifier
, if it
corresponds to an OCL primitive type.
type
- the type to convert to an OCL type
public static org.eclipse.emf.ecore.EClassifier getOCLCollectionType(org.eclipse.emf.ecore.EClassifier type, boolean isOrdered, boolean isUnique)
EClassifier
,
according to the collection's orderedness and uniqueness. The mapping is
as follows:
Note that the collection's element type
is mapped to an
OCL primitive type where possible.
type
- the type to get the corresponding OCL collection type forisOrdered
- whether the OCL type should be orderedisUnique
- whether the OCL type should be unique
EcoreEnvironment.getOCLType(EClassifier)
public EnvironmentFactory getFactory()
Environment
getFactory
in interface Environment
EnvironmentFactory.createEnvironment(Environment)
protected void setFactory(EnvironmentFactory factory)
factory
- my originating factorypublic void setParent(Environment env)
setParent
in interface Environment
env
- public Environment getParent()
getParent
in interface Environment
public org.eclipse.emf.ecore.EClassifier getContextClassifier()
Environment
getContextClassifier
in interface Environment
public org.eclipse.emf.ecore.EOperation getContextOperation()
Environment
getContextOperation
in interface Environment
null
if this is not an
operation environmentpublic void setContextOperation(org.eclipse.emf.ecore.EOperation operation)
public org.eclipse.emf.ecore.EStructuralFeature getContextProperty()
Environment
getContextProperty
in interface Environment
null
if this is not a
property environmentpublic void setContextProperty(org.eclipse.emf.ecore.EStructuralFeature property)
public TypeResolver getTypeResolver()
PersistentEnvironment
getTypeResolver
in interface PersistentEnvironment
protected TypeResolver createTypeResolver()
public boolean isEmpty()
isEmpty
in interface Environment
public Variable lookupLocal(java.lang.String name)
lookupLocal
in interface Environment
name
-
public Variable lookup(java.lang.String name)
lookup
in interface Environment
name
-
public org.eclipse.emf.ecore.EPackage lookupPackage(java.util.List path)
Environment
null
.
lookupPackage
in interface Environment
path
- the path name
null
if not foundpublic org.eclipse.emf.ecore.EClassifier lookupPathName(java.util.List names)
lookupPathName
in interface Environment
names
-
public void setSelfVariable(Variable var)
Environment
setSelfVariable
in interface Environment
var
- the "self" variablepublic Variable getSelfVariable()
Environment
getSelfVariable
in interface Environment
null
if none (which should not
happen as there is always some classifier context)public boolean addElement(java.lang.String name, Variable elem, boolean exp)
addElement
in interface Environment
name
- elem
- --
variable declarationexp
- --
is the variable implicit?
public void deleteElement(java.lang.String name)
deleteElement
in interface Environment
name
- public java.util.Collection getVariables()
Environment
Variable
s registered in me explicitly.
getVariables
in interface Environment
public org.eclipse.emf.ecore.EOperation lookupOperation(org.eclipse.emf.ecore.EClassifier owner, java.lang.String name, org.eclipse.emf.common.util.EList args)
Environment
lookupOperation
in interface Environment
owner
- the owner type of the called operationname
- the name of the called operationargs
- the arguments (as OCLExpression
s) passed to the operation
null
if not foundpublic org.eclipse.emf.ecore.EClass lookupSignal(org.eclipse.emf.ecore.EClassifier owner, java.lang.String name, org.eclipse.emf.common.util.EList args)
Environment
lookupSignal
in interface Environment
owner
- the owner type of the signal receptionname
- the name of the signalargs
- the arguments (as OCLExpression
s) passed in the signal
null
if not foundpublic org.eclipse.emf.common.util.EList getSignals(org.eclipse.emf.ecore.EClassifier owner)
getSignals
in interface Environment
owner
- the owner type of the signal receptions
EClass
es), or an empty list if nonepublic org.eclipse.emf.ecore.EStructuralFeature lookupProperty(org.eclipse.emf.ecore.EClassifier owner, java.lang.String name)
Environment
lookupProperty
in interface Environment
name
- the property name
null
if it could not be foundpublic org.eclipse.emf.ecore.EClass lookupAssociationClassReference(org.eclipse.emf.ecore.EClassifier parentClassifier, java.lang.String name)
Environment
lookupAssociationClassReference
in interface Environment
parentClassifier
- the referencing class to searchname
- the association class name (with an initial lower case as
per the OCL convention)
null
if the specified
parent
classifier does not have any references
implemented by the named association classpublic static java.lang.String initialLower(org.eclipse.emf.ecore.ENamedElement elem)
elem
ent with its initial character
in lower case.
elem
- a named element
public org.eclipse.emf.common.util.EList getStates(org.eclipse.emf.ecore.EClassifier owner, java.util.List pathPrefix)
EcoreEnvironment.collectStates(org.eclipse.emf.ecore.EClassifier, java.util.List, java.util.List)
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
EcoreEnvironment.collectStates(org.eclipse.emf.ecore.EClassifier, java.util.List, java.util.List)
method.
getStates
in interface Environment
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 names
protected void collectStates(org.eclipse.emf.ecore.EClassifier owner, java.util.List pathPrefix, java.util.List states)
Implementors must only provide the states defined directly in the namespace indicated by the path prefix (i.e., only one level).
owner
- the owner typepathPrefix
- partialstates
- a list of states directly owned by the namespace indicated
by path prefix, within the owner typepublic java.lang.String getStateName(org.eclipse.emf.ecore.EObject state)
getStateName
in interface Environment
state
- representation of a UML state
public Variable lookupImplicitSourceForProperty(java.lang.String name)
Environment
lookupImplicitSourceForProperty
in interface Environment
name
- the property name
public Variable lookupImplicitSourceForAssociationClass(java.lang.String name)
Environment
lookupImplicitSourceForAssociationClass
in interface Environment
name
- the association class name to seek
null
if none
is foundpublic static org.eclipse.emf.ecore.EPackage findPackage(java.util.List packageNames)
packageNames
- the qualified package name
null
if not foundpublic static org.eclipse.emf.ecore.EPackage findPackage(java.util.List packageNames, org.eclipse.emf.ecore.EPackage.Registry registry)
packageNames
- the qualified package nameregistry
- the EPackage.Registry to look in
null
if not foundpublic Variable lookupImplicitSourceForOperation(java.lang.String name, org.eclipse.emf.common.util.EList params) throws SemanticException
Environment
lookupImplicitSourceForOperation
in interface Environment
name
-
SemanticException
public java.lang.String getDescription(org.eclipse.emf.ecore.ENamedElement namedElement)
eClass
or, if it is an
ETypedElement
, the name of its type.
getDescription
in interface Environment
namedElement
- a named element obtained by adaptation of a user
model element
public boolean isQuery(org.eclipse.emf.ecore.EOperation operation)
operation
is a query
operation. Note that an environment that correctly supports query
operations would need to supply appropriately annotated
EOperation
s or otherwise override this method.
isQuery
in interface Environment
operation
- an operation
EOperation
that
is not annotated is considered to be a query by defaultpublic boolean isAssociationClass(org.eclipse.emf.ecore.EClass eclass)
eclass
is an association
class. Note that an environment that correctly supports association
classes would need to supply appropriately annotated EClass
es.
isAssociationClass
in interface Environment
eclass
- an Ecore class
public org.eclipse.emf.ecore.EClass getAssociationClass(org.eclipse.emf.ecore.EReference reference)
EClass
, if any. This gets the "class" aspect of the
association class, for which the reference represents the "association"
aspect. Note that an environment that correctly supports association
classes would need to supply appropriately annotated EReference
s.
getAssociationClass
in interface Environment
reference
- a reference
null
if the reference
does not represent an association classpublic org.eclipse.emf.common.util.EList getMemberEnds(org.eclipse.emf.ecore.EClass associationClass)
EReference
s. Note that an environment that correctly supports
association classes would need to supply appropriately annotated
EClass
es.
getMemberEnds
in interface Environment
associationClass
- an EClass representing an association class
EReference
s representing its member ends (the
association roles)public org.eclipse.emf.common.util.EList getQualifiers(org.eclipse.emf.ecore.EStructuralFeature property)
EReference
s.
getQualifiers
in interface Environment
property
- a property of the model class
EStructuralFeature
s, or an
empty list if the property has no qualifiers
|
Copyright 2002, 2006 IBM Corporation and others. All Rights Reserved. |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |