|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.eclipse.ocl.examples.pivot.OCL
public class OCL
Convenient subclass of the OCL façade that binds the
Ecore 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 the shared
EcoreEnvironmentFactory instance.
EcoreEnvironmentFactory| Constructor Summary | |
|---|---|
protected |
OCL(EnvironmentFactory envFactory,
Environment rootEnv)
Initializes me with my environment factory and root environment. |
| Method Summary | |
|---|---|
boolean |
check(java.lang.Object context,
Constraint constraint)
Checks whether a constraint is satisfied by an object. |
boolean |
check(java.lang.Object context,
ExpressionInOCL specification)
Checks whether a constraint, specified simply as an OCL expression, is satisfied by an object. |
EvaluationVisitor |
createEvaluationVisitor(java.lang.Object context,
ExpressionInOCL expression)
Creates a new evaluation visitor, for the evaluation of an OCL expression in a context. |
OCLHelper |
createOCLHelper()
Creates a new OCLHelper instance for convenient parsing of
embedded constraints and query expressions in this environment. |
OCLHelper |
createOCLHelper(org.eclipse.emf.ecore.EObject element)
Creates a new OCLHelper instance for convenient parsing of
embedded constraints and query expressions in the nested environment
of a specified element which mya be a Type, Operation or Property. |
Query |
createQuery(Constraint constraint)
Creates a new Query encapsulating a constraint with the current
environment and extent map. |
Query |
createQuery(ExpressionInOCL specification)
Creates a new Query encapsulating a query expression with the
current environment and extent map. |
org.eclipse.emf.ecore.resource.Resource |
cs2pivot(BaseResource csResource)
Return the Pivot resource counterpart of an Xtext csResource. |
void |
dispose()
Disposes any objects that I have created while I have been in use. |
ASResource |
ecore2pivot(org.eclipse.emf.ecore.resource.Resource ecoreResource)
Return the Pivot resource counterpart of an ecoreResource. |
java.lang.Object |
evaluate(java.lang.Object context,
ExpressionInOCL expression)
Evaluates a query expression on a context object (which is bound to the self variable). |
java.util.List<Constraint> |
getConstraints()
Obtains all of the constraints parsed hitherto by this OCL instance. |
Environment |
getEnvironment()
Obtains the root OCL parsing environment. |
EnvironmentFactory |
getEnvironmentFactory()
|
EvaluationEnvironment |
getEvaluationEnvironment()
Deprecated. no longer called |
org.eclipse.emf.common.util.Diagnostic |
getEvaluationProblems()
Obtains problems, if any, occurred during evaluation of the last OCL constraint or query expression. |
MetaModelManager |
getMetaModelManager()
|
DomainModelManager |
getModelManager()
Obtains the model manager, if any, provided by the client to customize the evaluation of constraints. |
int |
getParserRepairCount()
Queries the number of repairs to be made by the parser. |
org.eclipse.emf.common.util.Diagnostic |
getProblems()
Obtains problems, if any, found in parsing the last OCL constraint or query expression. |
ExpressionInOCL |
getSpecification(Constraint constraint)
Return the Constraint specification as an ExpressionInOCL, parsing any OpaqueExpression that may be encountered. |
static java.lang.String |
initialize(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Initialize registries to support OCL and Ecore usage. |
boolean |
isEvaluationTracingEnabled()
Queries whether tracing of evaluation is enabled. |
boolean |
isParseTracingEnabled()
Queries whether tracing of parsingis enabled. |
BaseResource |
load(org.eclipse.emf.common.util.URI uri)
Load the Complete OCL document specified by the URI into the external ResourceSet and return the concrete syntax resource. |
static OCL |
newInstance()
Creates a new OCL with no initial Ecore package registry. |
static OCL |
newInstance(Environment env)
Creates a new OCL using the specified initial Ecore
environment. |
static OCL |
newInstance(EnvironmentFactory envFactory)
Creates a new OCL using the specified Ecore environment
factory. |
static OCL |
newInstance(EnvironmentFactory envFactory,
org.eclipse.emf.ecore.resource.Resource resource)
Creates a new OCL using the specified Ecore environment
factory and a resource from which to load the initial environment. |
static OCL |
newInstance(org.eclipse.emf.ecore.EPackage.Registry reg)
Creates a new OCL using the specified Ecore package registry. |
org.eclipse.emf.ecore.resource.Resource |
parse(org.eclipse.emf.common.util.URI uri)
Load the Complete OCL document specified by the URI into the external ResourceSet and parse the concrete syntax resource returning the resulting abstract syntax resource. |
void |
pivot2cs(ASResource asResource,
BaseResource csResource)
Update the CS resource from a asResource. |
org.eclipse.emf.ecore.resource.Resource |
pivot2ecore(org.eclipse.emf.ecore.resource.Resource asResource,
org.eclipse.emf.common.util.URI uri)
Return the Ecore resource counterpart of a asResource, specifying the uri of the resulting Ecore resource. |
void |
setEvaluationTracingEnabled(boolean b)
Sets whether tracing of evaluation is enabled. |
void |
setModelManager(DomainModelManager modelManager)
Assigns a custom extent map to define the extents of classes in evaluation of OCL constraints. |
void |
setParserRepairCount(int parserRepairCount)
Sets the number of repairs to be made by the parser. |
void |
setParseTracingEnabled(boolean b)
Sets whether tracing of parsing is enabled. |
ASResource |
uml2pivot(org.eclipse.emf.ecore.resource.Resource umlResource)
Return the Pivot resource counterpart of a umlResource. |
void |
validate(Constraint constraint)
Validates an OCL constraint, which may have been loaded from some resource or constructed via the API (perhaps by translation from some other language). |
void |
validate(OCLExpression expression)
Validates an OCL expression, which may have been loaded from some resource or constructed via the API (perhaps by translation from some other language). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected OCL(@NonNull
EnvironmentFactory envFactory,
@NonNull
Environment rootEnv)
envFactory - my environment factoryrootEnv - my root environment| Method Detail |
|---|
public static java.lang.String initialize(@Nullable
org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
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 a specific package registry.
This method is used to configure the ResourceSet used to load the OCL Standard Library.
resourceSet - to be initialized or null for global initialization
@NonNull public static OCL newInstance()
OCL with no initial Ecore package registry.
This automatically creates a new EnvironmentFactory and MetaModelManager.
OCL
@NonNull
public static OCL newInstance(@NonNull
org.eclipse.emf.ecore.EPackage.Registry reg)
OCL using the specified Ecore package registry.
This automatically creates an new EnvironmentFactory and MetaModelManager.
reg - Ecore package registry
OCL
@NonNull
public static OCL newInstance(@NonNull
EnvironmentFactory envFactory)
OCL using the specified Ecore environment
factory.
envFactory - an environment factory for Ecore
OCL
@NonNull
public static OCL newInstance(@NonNull
EnvironmentFactory envFactory,
@NonNull
org.eclipse.emf.ecore.resource.Resource resource)
OCL using the specified Ecore environment
factory and a resource from which to load the initial environment.
envFactory - an environment factory for Ecoreresource - the resource containing a persistent environment
(which may be empty for an initially empty environment)
OCL
@NonNull
public static OCL newInstance(@NonNull
Environment env)
OCL using the specified initial Ecore
environment.
env - an environment for Ecore
OCL
public boolean check(java.lang.Object context,
@NonNull
Constraint constraint)
context - the self object of the constraintconstraint - the constraint to check
#check(Object, OCLExpression),
#evaluate(Object, OCLExpression)
public boolean check(java.lang.Object context,
@NonNull
ExpressionInOCL specification)
context - the self object of the constraintconstraint - the constraint to check, which must be a boolean-valued
expression
java.lang.IllegalArgumentException - if the constraint expression is not boolean-valued#check(Object, Object),
#evaluate(Object, OCLExpression)
@NonNull
public EvaluationVisitor createEvaluationVisitor(@Nullable
java.lang.Object context,
@NonNull
ExpressionInOCL expression)
@NonNull public OCLHelper createOCLHelper()
OCLHelper instance for convenient parsing of
embedded constraints and query expressions in this environment. The
helper is particularly 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.
@NonNull
public OCLHelper createOCLHelper(@NonNull
org.eclipse.emf.ecore.EObject element)
OCLHelper instance for convenient parsing of
embedded constraints and query expressions in the nested environment
of a specified element which mya be a Type, Operation or Property. 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.
@NonNull
public Query createQuery(@NonNull
ExpressionInOCL specification)
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.
query - the OCL query expression, which may be interpreted as a
constraint if it is boolean-valued
#createQuery(Object)
public Query createQuery(@NonNull
Constraint constraint)
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.
constraint - the OCL constraint
#createQuery(OCLExpression)
@NonNull
public org.eclipse.emf.ecore.resource.Resource cs2pivot(@NonNull
BaseResource csResource)
public void dispose()
constraints that I
have parsed and disposing of
my environment.
@NonNull
public ASResource ecore2pivot(@NonNull
org.eclipse.emf.ecore.resource.Resource ecoreResource)
throws ParserException
ParserException
@Nullable
public java.lang.Object evaluate(@Nullable
java.lang.Object context,
@NonNull
ExpressionInOCL expression)
#isInvalid(Object) method to check whether the evaluation result
is OclInvalid.
context - the context (self) objectexpression - the OCL expression to evaluate
#isInvalid(Object),
#check(Object, Object)@NonNull public java.util.List<Constraint> getConstraints()
#parse(OCLInput)@NonNull public Environment getEnvironment()
@NonNull public EnvironmentFactory getEnvironmentFactory()
@Deprecated @NonNull public EvaluationEnvironment getEvaluationEnvironment()
getEnvironment()@Nullable public org.eclipse.emf.common.util.Diagnostic getEvaluationProblems()
null if all was OK@NonNull public MetaModelManager getMetaModelManager()
@Nullable public DomainModelManager getModelManager()
null if
thie OCL is using the default dynamic extent map implementationpublic int getParserRepairCount()
Queries the number of repairs to be made by the parser.
The default zero value selects use of the deterministic parser, which terminates after one serious syntax error is detected.
A non-zero value selects the backtracking parser. The backtracking parser may be about three times slower.
setParserRepairCount(int)@Nullable public org.eclipse.emf.common.util.Diagnostic getProblems()
null if all was OK
@Nullable
public ExpressionInOCL getSpecification(@NonNull
Constraint constraint)
throws ParserException
ParserExceptionpublic boolean isEvaluationTracingEnabled()
In an Eclipse environment, tracing is also enabled by turning on the org.eclipse.ocl/debug/evaluation debug option.
setEvaluationTracingEnabled(boolean)public boolean isParseTracingEnabled()
In an Eclipse environment, tracing is also enabled by turning on the org.eclipse.ocl/debug/parsing debug option.
setParseTracingEnabled(boolean)
@Nullable
public BaseResource load(@NonNull
org.eclipse.emf.common.util.URI uri)
@Nullable
public org.eclipse.emf.ecore.resource.Resource parse(@NonNull
org.eclipse.emf.common.util.URI uri)
public void pivot2cs(@NonNull
ASResource asResource,
@NonNull
BaseResource csResource)
(BaseResource) resourceSet.createResource(outputURI, OCLinEcoreCSPackage.eCONTENT_TYPE);
@NonNull
public org.eclipse.emf.ecore.resource.Resource pivot2ecore(@NonNull
org.eclipse.emf.ecore.resource.Resource asResource,
@NonNull
org.eclipse.emf.common.util.URI uri)
throws java.io.IOException
java.io.IOExceptionpublic void setEvaluationTracingEnabled(boolean b)
In an Eclipse environment, tracing is also enabled by turning on the org.eclipse.ocl/debug/evaluation debug option.
b - whether evaluation tracing is enabledisEvaluationTracingEnabled()
public void setModelManager(@Nullable
DomainModelManager modelManager)
modelManager - a custom extent map, or null to use the default
dynamic extent map implementationpublic void setParserRepairCount(int parserRepairCount)
Sets the number of repairs to be made by the parser.
The default zero value selects use of the deterministic parser, which terminates after one serious syntax error is detected.
A non-zero value selects the backtracking parser. The backtracking parser may be about three times slower.
parserRepairCount - whether evaluation tracing is enabled
java.lang.IllegalArgumentException - if the parserRepairCount is negativegetParserRepairCount()public void setParseTracingEnabled(boolean b)
In an Eclipse environment, tracing is also enabled by turning on the org.eclipse.ocl/debug/parsing debug option.
param b whether parsing tracing is enabled
isParseTracingEnabled()
@NonNull
public ASResource uml2pivot(@NonNull
org.eclipse.emf.ecore.resource.Resource umlResource)
throws ParserException
ParserException
public void validate(@NonNull
OCLExpression expression)
throws SemanticException
expression - an expression to validate
SemanticException - on detection of any well-formedness problem in the expression#validate(Object)
public void validate(@NonNull
Constraint constraint)
throws SemanticException
constraint - a constraint to validate
SemanticException - on detection of any well-formedness problem in the constraint
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||