|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.ocl.OCL<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
public class OCL<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
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.
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 |
OCL(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> env)
Initializes me with a root environment. |
protected |
OCL(EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> envFactory)
Initializes me with an environment factory, which I will use to create a root environment. |
protected |
OCL(EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> envFactory,
Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> rootEnv)
Initializes me with my environment factory and root environment. |
protected |
OCL(EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> envFactory,
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(Object context,
CT constraint)
Checks whether a constraint is satisfied by an object. |
|
boolean |
check(Object context,
OCLExpression<C> constraint)
Checks whether a constraint, specified simply as an OCL expression, is satisfied by an object. |
|
OCLHelper<C,O,P,CT> |
createOCLHelper()
Creates a new OCLHelper instance for convenient parsing of
embedded constraints and query expressions in this environment. |
|
Query<C,CLS,E> |
createQuery(CT constraint)
Creates a new Query encapsulating a constraint with the
current environment and extent map. |
|
Query<C,CLS,E> |
createQuery(OCLExpression<C> query)
Creates a new Query encapsulating a query expression with the
current environment and extent map. |
|
Object |
evaluate(Object context,
OCLExpression<C> expression)
Evaluates a query expression on a context object (which is bound to the self variable). |
|
List<CT> |
getConstraints()
Obtains all of the constraints parsed hitherto by this OCL instance. |
|
Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> |
getEnvironment()
Obtains the OCL parsing environment. |
|
EvaluationEnvironment<C,O,P,CLS,E> |
getEvaluationEnvironment()
Obtains the OCL evaluation environment. |
|
Map<CLS,? extends Set<? extends E>> |
getExtentMap()
Obtains the extent map, if any, provided by the client to customize the evaluation of constraints. |
|
boolean |
isEvaluationTracingEnabled()
Queries whether tracing of evaluation is enabled. |
|
boolean |
isInvalid(Object value)
Queries whether a value is the special OclInvalid token. |
|
boolean |
isParseTracingEnabled()
Queries whether tracing of parsingis enabled. |
|
static
|
newInstance(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> env)
Creates a new OCL on the specified root environment. |
|
static
|
newInstance(EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> envFactory)
Creates a new OCL with an environment factory, which it will
use to create a root environment. |
|
static
|
newInstance(EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> envFactory,
Resource resource)
Creates a new OCL with an environment factory and a resource
in which its environment is to be persisted, or from which it may be
loaded if the resource already has content. |
|
List<CT> |
parse(OCLInput input)
Parses an OCL document, returning the constraints parsed from it. |
|
void |
setEvaluationTracingEnabled(boolean b)
Sets whether tracing of evaluation is enabled. |
|
void |
setExtentMap(Map<CLS,? extends Set<? extends E>> extentMap)
Assigns a custom extent map to define the extents of classes in evaluation of OCL constraints. |
|
void |
setParseTracingEnabled(boolean b)
Sets whether tracing of parsing is enabled. |
|
void |
validate(CT 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<C> 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(EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> envFactory)
envFactory
- my environment factoryprotected OCL(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> env)
env
- my root environmentprotected OCL(EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> envFactory, Resource resource)
envFactory
- an environment factoryresource
- a resource in which the root environment is persistedprotected OCL(EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> envFactory, Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> rootEnv)
envFactory
- my environment factoryrootEnv
- my root environmentMethod Detail |
---|
public static <PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> OCL<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> newInstance(EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> envFactory)
OCL
with an environment factory, which it will
use to create a root environment.
envFactory
- an environment factory
public static <PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> OCL<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> newInstance(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> env)
OCL
on the specified root environment.
env
- the root environment
public static <PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> OCL<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> newInstance(EnvironmentFactory<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> envFactory, Resource resource)
OCL
with an environment factory and a resource
in which its environment is to be persisted, or from which it may be
loaded if the resource already has content.
envFactory
- an environment factoryresource
- a resource in which the root environment is persisted
public Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> getEnvironment()
getEvaluationEnvironment()
public EvaluationEnvironment<C,O,P,CLS,E> getEvaluationEnvironment()
getEnvironment()
public Map<CLS,? extends Set<? extends E>> getExtentMap()
null
if
thie OCL is using the default dynamic extent map implementationpublic void setExtentMap(Map<CLS,? extends Set<? extends E>> extentMap)
extentMap
- a custom extent map, or null
to use the
default dynamic extent map implementationpublic List<CT> parse(OCLInput input) throws ParserException
OCL
instance remembers these constraints; they can
be retrieved later via the getConstraints()
method.
input
- an OCL document as either a string or a stream
ParserException
- on failure to parse, either because of a
syntactic or semantic problem or because of an I/O failuregetConstraints()
public List<CT> getConstraints()
parse(OCLInput)
public void validate(OCLExpression<C> expression) throws SemanticException
expression
- an expression to validate
SemanticException
- on detection of any well-formedness problem
in the expressionvalidate(Object)
public void validate(CT constraint) throws SemanticException
constraint
- a constraint to validate
SemanticException
- on detection of any well-formedness problem
in the constraintpublic Object evaluate(Object context, OCLExpression<C> 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 isInvalid(Object value)
value
- some OCL value
true
if it is the OclInvalid;
false
, otherwiseevaluate(Object, OCLExpression)
public boolean check(Object context, CT constraint)
context
- the self object of the constraintconstraint
- the constraint to check
check(Object, OCLExpression)
,
evaluate(Object, OCLExpression)
public boolean check(Object context, OCLExpression<C> constraint)
context
- the self object of the constraintconstraint
- the constraint to check, which must be a boolean-valued
expression
IllegalArgumentException
- if the constraint expression is not
boolean-valuedcheck(Object, Object)
,
evaluate(Object, OCLExpression)
public OCLHelper<C,O,P,CT> createOCLHelper()
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.
public Query<C,CLS,E> createQuery(OCLExpression<C> query)
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<C,CLS,E> createQuery(CT 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)
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 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.
param b whether evaluation tracing is enabled
isEvaluationTracingEnabled()
|
Copyright 2002, 2007 IBM Corporation and others. All Rights Reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |