org.eclipse.ocl.uml
Class OCL

java.lang.Object
  extended by org.eclipse.ocl.OCL<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject>
      extended by org.eclipse.ocl.uml.OCL

public class OCL
extends OCL<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject>

Convenient subclass of the OCL façade that binds the UML metamodel to the superclass's generic type parameters. This frees client code from the long list of parameter substitutions. This subclass also provides a shortcut to creating an OCL on a UMLEnvironmentFactory instance using its own resource set.

The parser environments created by the UML environment factory support OCL expressions at both the metamodel (M2) and user model (M1) levels. For user model constraints, use the classifier in the model as the context classifier in invocations of this OCL or an OCLHelper created by it. For metamodel OCL (used, for example, to query the user model, itself) use the metaclass of any element in the user model as the context classifier. A convenient way to obtain this metaclass is via the OCLUMLUtil.getMetaclass(org.eclipse.uml2.uml.Element) method.

Author:
Christian W. Damus (cdamus)
See Also:
UMLEnvironmentFactory

Nested Class Summary
static interface OCL.Helper
          Convenient interface aliasing the type parameter substitutions for the UML environment, for ease of typing.
static interface OCL.Query
          Convenient interface aliasing the type parameter substitutions for the UML environment, for ease of typing.
 
Constructor Summary
protected OCL(Environment<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject> env)
          Initializes me with an initial environment for the UML metamodel.
protected OCL(EnvironmentFactory<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject> envFactory)
          Initializes me with an environment factory for the UML metamodel.
protected OCL(EnvironmentFactory<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject> envFactory, org.eclipse.emf.ecore.resource.Resource resource)
          Initializes me with an environment factory for the UML metamodel and a resource from which to load my root environment.
 
Method Summary
 OCL.Helper createOCLHelper()
          Creates a new OCLHelper instance for convenient parsing of embedded constraints and query expressions in this environment.
 OCL.Query createQuery(org.eclipse.uml2.uml.Constraint constraint)
          Creates a new Query encapsulating a constraint with the current environment and extent map.
 OCL.Query createQuery(OCLExpression<org.eclipse.uml2.uml.Classifier> query)
          Creates a new Query encapsulating a query expression with the current environment and extent map.
static java.lang.String initialize(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
          Initialize registries to support OCL and UML usage.
static OCL newInstance()
          Creates a new OCL using a new UML environment factory that uses a private resource set and the global package registry for looking up Ecore representations of UML packages.
static OCL newInstance(Environment<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject> env)
          Creates a new OCL using the specified initial UML environment.
static OCL newInstance(EnvironmentFactory<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject> envFactory)
          Creates a new OCL using the specified UML environment factory.
static OCL newInstance(EnvironmentFactory<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject> envFactory, org.eclipse.emf.ecore.resource.Resource resource)
          Creates a new OCL using the specified UML environment factory and a resource from which to load the initial environment.
static OCL newInstance(org.eclipse.emf.ecore.resource.ResourceSet rset)
          Creates a new OCL using a new UML environment factory that uses the specified resource set and its local package registry for looking up Ecore representations of UML packages.
 
Methods inherited from class org.eclipse.ocl.OCL
check, check, createAnalyzer, dispose, evaluate, getConstraints, getEnvironment, getEvaluationEnvironment, getEvaluationProblems, getExtentMap, getParserRepairCount, getProblems, isEvaluationTracingEnabled, isInvalid, isParseTracingEnabled, newInstance, newInstance, newInstance, parse, setEvaluationTracingEnabled, setExtentMap, setParserRepairCount, setParseTracingEnabled, validate, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OCL

protected OCL(EnvironmentFactory<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject> envFactory)
Initializes me with an environment factory for the UML metamodel.

Parameters:
envFactory - my environment factory

OCL

protected OCL(Environment<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject> env)
Initializes me with an initial environment for the UML metamodel.

Parameters:
env - my root environment

OCL

protected OCL(EnvironmentFactory<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject> envFactory,
              org.eclipse.emf.ecore.resource.Resource resource)
Initializes me with an environment factory for the UML metamodel and a resource from which to load my root environment.

Parameters:
envFactory - my environment factory
resource - my persisted root environment
Method Detail

initialize

public static java.lang.String initialize(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Initialize registries to support OCL and UML usage. This method is intended for initialization of standalone behaviors for which plugin extension registrations have not been applied.

A null resourceSet may be provided to initialize the global package registry and global URI mapping registry.

A non-null resourceSet may be provided to identify specific package and global URI mapping registries.

This method is used to configure the ResourceSet used to load the OCL Standard Library.

Parameters:
resourceSet - to be initialized or null for global initialization
Returns:
a failure reason, null if successful
Since:
3.0

newInstance

public static OCL newInstance()
Creates a new OCL using a new UML environment factory that uses a private resource set and the global package registry for looking up Ecore representations of UML packages.

Returns:
the new OCL

newInstance

public static OCL newInstance(org.eclipse.emf.ecore.resource.ResourceSet rset)
Creates a new OCL using a new UML environment factory that uses the specified resource set and its local package registry for looking up Ecore representations of UML packages.

Parameters:
rset - a resource set containing UML models
Returns:
the new OCL

newInstance

public static OCL newInstance(EnvironmentFactory<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject> envFactory)
Creates a new OCL using the specified UML environment factory.

Parameters:
envFactory - an environment factory for UML
Returns:
the new OCL

newInstance

public static OCL newInstance(Environment<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject> env)
Creates a new OCL using the specified initial UML environment.

Parameters:
env - an environment for UML
Returns:
the new OCL

newInstance

public static OCL newInstance(EnvironmentFactory<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject> envFactory,
                              org.eclipse.emf.ecore.resource.Resource resource)
Creates a new OCL using the specified UML environment factory and a resource from which to load the initial environment.

Parameters:
envFactory - an environment factory for UML
resource - the resource containing a persistent environment (which may be empty for an initially empty environment)
Returns:
the new OCL

createOCLHelper

public OCL.Helper createOCLHelper()
Creates a new OCLHelper instance for convenient parsing of embedded constraints and query expressions in this environment. The helper is particulary useful for parsing constraints embedded in the model, in which case the context of a constraint is determined by its placement and the textual context declarations are unnecessary.

The return type is narrowed to the UML binding for the generic OCLHelper<C, O, P, CT> type.

Overrides:
createOCLHelper in class OCL<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject>
Returns:
a new helper object

createQuery

public OCL.Query createQuery(org.eclipse.uml2.uml.Constraint constraint)
Creates a new Query encapsulating a constraint with the current environment and extent map. This is convenient for repeated evaluation of constraints and for filtering objects using the constraint expression.

Every query maintains its own evaluation environment, which enables concurrent evaluation (where this may be safe in an EMF-based model) and different bindings for client-supplied "global" variables.

The return type is narrowed to the UML binding for the generic Query<C, CLS, E> type.

Overrides:
createQuery in class OCL<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject>
Parameters:
constraint - the OCL constraint
Returns:
the new query object
See Also:
OCL.createQuery(OCLExpression)

createQuery

public OCL.Query createQuery(OCLExpression<org.eclipse.uml2.uml.Classifier> query)
Creates a new Query encapsulating a query expression with the current environment and extent map. This is convenient for repeated evaluation of expressions and for filtering/transforming objects using a query or constraint expression.

Every query maintains its own evaluation environment, which enables concurrent evaluation (where this may be safe in an EMF-based model) and different bindings for client-supplied "global" variables.

The return type is narrowed to the UML binding for the generic Query<C, CLS, E> type.

Overrides:
createQuery in class OCL<org.eclipse.uml2.uml.Package,org.eclipse.uml2.uml.Classifier,org.eclipse.uml2.uml.Operation,org.eclipse.uml2.uml.Property,org.eclipse.uml2.uml.EnumerationLiteral,org.eclipse.uml2.uml.Parameter,org.eclipse.uml2.uml.State,org.eclipse.uml2.uml.CallOperationAction,org.eclipse.uml2.uml.SendSignalAction,org.eclipse.uml2.uml.Constraint,org.eclipse.uml2.uml.Class,org.eclipse.emf.ecore.EObject>
Parameters:
query - the OCL query expression, which may be interpreted as a constraint if it is boolean-valued
Returns:
the new query object
See Also:
OCL.createQuery(Object)