|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.ocl.examples.pivot.OCLBase
public abstract class OCLBase
The Façade for parsing and evaluation of OCL documents and
constraints. The OCL
is initialized with an environment factory
that supports the metamodel of the model to which the OCL constraints are to
be applied.
Since 1.2, the helper supplies diagnostics indicating any problems encountered while parsing. The diagnostics pertain always to the most recently executed parse operation.
See the Environment
class for a description of the generic type
parameters of this class.
Providers of OCL bindings for metamodels may extend this class for the convenience of their clients, to specify the type parameter substitutions.
Constructor Summary | |
---|---|
protected |
OCLBase(Environment env)
Initializes me with a root environment. |
protected |
OCLBase(EnvironmentFactory envFactory)
Initializes me with an environment factory, which I will use to create a root environment. |
protected |
OCLBase(EnvironmentFactory envFactory,
Environment rootEnv)
Initializes me with my environment factory and root environment. |
protected |
OCLBase(EnvironmentFactory envFactory,
org.eclipse.emf.ecore.resource.Resource resource)
Initializes me with an environment factory and a resource in which my environment is to be persisted, or from which it may be loaded if the resource already has content. |
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. |
QueryBase |
createQuery(Constraint constraint)
Creates a new QueryBase encapsulating a constraint with the current
environment and extent map. |
QueryBase |
createQuery(ExpressionInOcl specification)
Creates a new QueryBase encapsulating a query expression with the
current environment and extent map. |
void |
dispose()
Disposes any objects that I have created while I have been in use. |
Value |
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 OCL parsing environment. |
EnvironmentFactory |
getEnvironmentFactory()
|
EvaluationEnvironment |
getEvaluationEnvironment()
Obtains the OCL evaluation environment. |
org.eclipse.emf.common.util.Diagnostic |
getEvaluationProblems()
Obtains problems, if any, occurred during evaluation of the last OCL constraint or query expression. |
ModelManager |
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. |
TypeManager |
getTypeManager()
|
ValueFactory |
getValueFactory()
|
boolean |
isEvaluationTracingEnabled()
Queries whether tracing of evaluation is enabled. |
boolean |
isParseTracingEnabled()
Queries whether tracing of parsingis enabled. |
void |
setEvaluationTracingEnabled(boolean b)
Sets whether tracing of evaluation is enabled. |
void |
setModelManager(ModelManager 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. |
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 OCLBase(EnvironmentFactory envFactory)
envFactory
- my environment factoryprotected OCLBase(Environment env)
env
- my root environmentprotected OCLBase(EnvironmentFactory envFactory, org.eclipse.emf.ecore.resource.Resource resource)
envFactory
- an environment factoryresource
- a resource in which the root environment is persistedprotected OCLBase(EnvironmentFactory envFactory, Environment rootEnv)
envFactory
- my environment factoryrootEnv
- my root environmentMethod Detail |
---|
public Environment getEnvironment()
getEvaluationEnvironment()
public EnvironmentFactory getEnvironmentFactory()
public EvaluationEnvironment getEvaluationEnvironment()
getEnvironment()
public ModelManager getModelManager()
null
if
thie OCL is using the default dynamic extent map implementationpublic void setModelManager(ModelManager modelManager)
modelManager
- a custom extent map, or null
to use the default
dynamic extent map implementationpublic java.util.List<Constraint> getConstraints()
#parse(OCLInput)
public void validate(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(Constraint constraint) throws SemanticException
constraint
- a constraint to validate
SemanticException
- on detection of any well-formedness problem in the constraintpublic Value evaluate(java.lang.Object context, 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)
public boolean check(java.lang.Object context, 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, 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)
public QueryBase createQuery(ExpressionInOcl specification)
QueryBase
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 QueryBase createQuery(Constraint constraint)
QueryBase
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)
public boolean isParseTracingEnabled()
In an Eclipse environment, tracing is also enabled by turning on the org.eclipse.ocl/debug/parsing debug option.
setParseTracingEnabled(boolean)
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()
public 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)
public 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 boolean isEvaluationTracingEnabled()
In an Eclipse environment, tracing is also enabled by turning on the org.eclipse.ocl/debug/evaluation debug option.
setEvaluationTracingEnabled(boolean)
public 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 org.eclipse.emf.common.util.Diagnostic getProblems()
null
if all was OKpublic TypeManager getTypeManager()
public ValueFactory getValueFactory()
public org.eclipse.emf.common.util.Diagnostic getEvaluationProblems()
null
if all was OKpublic void dispose()
constraints
that I
have parsed and disposing of
my environment.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |