|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface OCLHelper<C,O,P,CT>
A utility object that provides OCL syntax completion suggestions for OCL expressions and convenient API for parsing OCL constraint expressions without the encumbrance of context declarations. The latter is most useful for processing OCL constraints and expressions embedded in the user model, where the context is implied by the placement of the constraint in the model.
An OCL helper is created by the OCL.createOCLHelper()
factory method
and inherits the current context Environment
of the OCL
that
created it.
Since 1.2, the helper supplies diagnostics indicating any problems encountered while parsing. The diagnostics pertain always to the most recently executed parse operation.
Note that this interface is not intended to be implemented by clients.
See the Environment
class for a description of the
generic type parameters of this class.
OCL.createOCLHelper()
Method Summary | |
---|---|
CT |
createBodyCondition(String expression)
Creates an operation body. |
CT |
createConstraint(ConstraintKind kind,
String expression)
Creates a constraint of the specified kind, by parsing the given expression. |
CT |
createDerivedValueExpression(String expression)
Creates a property derived value expression. |
CT |
createInitialValueExpression(String expression)
Creates a property initial value expression. |
CT |
createInvariant(String expression)
Creates an invariant constraint in the current classifier context. |
CT |
createPostcondition(String expression)
Creates an operation postcondition constraint. |
CT |
createPrecondition(String expression)
Creates an operation precondition constraint. |
OCLExpression<C> |
createQuery(String expression)
Creates a query expression in the current classifier context. |
P |
defineAttribute(String defExpression)
Defines an additional attribute in the context classifier, for use in formulating OCL queries and constraints. |
O |
defineOperation(String defExpression)
Defines an additional operation in the context classifier, for use in formulating OCL queries and constraints. |
P |
getContextAttribute()
Obtains my context attribute, if my environment is an attribute context. |
C |
getContextClassifier()
Obtains my OCL context classifier as a classifier. |
O |
getContextOperation()
Obtains my context operation, if my environment is an operation context. |
Environment<?,C,O,P,?,?,?,?,?,CT,?,?> |
getEnvironment()
Obtains the environment defining my current classifier, operation, or attribute context. |
OCL<?,C,O,P,?,?,?,?,?,CT,?,?> |
getOCL()
Obtains the OCL instance that created me. |
Diagnostic |
getProblems()
Obtains problems, if any, found in parsing the last OCL constraint or query expression. |
List<Choice> |
getSyntaxHelp(ConstraintKind constraintType,
String txt)
Obtains syntax completion choices for the specified fragment of an OCL expression given that it is intended for a constraint of the specified kind. |
boolean |
isValidating()
Queries whether I validate the expressions that I parse. |
void |
setAttributeContext(C context,
P property)
Sets the attribute context of the OCL expression for which syntax or parsing help is to be provided. |
void |
setContext(C context)
Sets the classifier context of the OCL expression for which syntax or parsing help is to be provided. |
void |
setInstanceAttributeContext(Object instance,
P property)
Sets the operation context implied by the specified instance. |
void |
setInstanceContext(Object instance)
Sets the classifier context implied by the specified instance. |
void |
setInstanceOperationContext(Object instance,
O operation)
Sets the operation context implied by the specified instance. |
void |
setOperationContext(C context,
O operation)
Sets the operation context of the OCL expression for which syntax or parsing help is to be provided. |
void |
setValidating(boolean validating)
Sets whether I should validate the expressions that I parse. |
Method Detail |
---|
void setContext(C context)
context
- the OCL context classifiersetOperationContext(Object, Object)
,
setAttributeContext(Object, Object)
C getContextClassifier()
null
)void setOperationContext(C context, O operation)
context
- the OCL context classifieroperation
- the OCL context operationsetContext(Object)
O getContextOperation()
null
if there is only a
classifier or attribute contextvoid setAttributeContext(C context, P property)
context
- the OCL context classifierproperty
- the OCL context attributesetContext(Object)
P getContextAttribute()
null
if there is only a
classifier or operation contextvoid setInstanceContext(Object instance)
This method is convenient for ad hoc parsing and evaluation of OCL constraints or expressions in the context of a model instance.
instance
- the OCL context instancesetContext(Object)
void setInstanceOperationContext(Object instance, O operation)
This method is convenient for ad hoc parsing and evaluation of OCL constraints or expressions in the context of a model instance.
instance
- the OCL context instanceoperation
- the OCL context operationsetOperationContext(Object, Object)
void setInstanceAttributeContext(Object instance, P property)
This method is convenient for ad hoc parsing and evaluation of OCL constraints or expressions in the context of a model instance.
instance
- the OCL context instanceproperty
- the OCL context attributesetAttributeContext(Object, Object)
OCL<?,C,O,P,?,?,?,?,?,CT,?,?> getOCL()
Environment<?,C,O,P,?,?,?,?,?,CT,?,?> getEnvironment()
null
if I have
not yet been assigned a contextsetContext(Object)
,
setOperationContext(Object, Object)
,
setAttributeContext(Object, Object)
boolean isValidating()
void setValidating(boolean validating)
validating
- whether I should validate parsed expressionsOCLExpression<C> createQuery(String expression) throws ParserException
expression
- the expression (without any context declaration).
This expression can have any result type; it needs not be a boolean
ParserException
- if the expression
fails to parseCT createConstraint(ConstraintKind kind, String expression) throws ParserException
attribute-name : type = expr
operation-name(parameters?) : type = expr
kind
- the kind of constraint to createexpression
- the constraint body
ParserException
- on failure to parse the constraintCT createInvariant(String expression) throws ParserException
expression
- the constraint expression (without any context
declaration). This must be a boolean-valued expression
ParserException
- if the expression
fails to parseCT createPrecondition(String expression) throws ParserException
expression
- the constraint expression (without any context
declaration). This must be a boolean-valued expression
ParserException
- if the expression
fails to parsesetOperationContext(Object, Object)
CT createPostcondition(String expression) throws ParserException
expression
- the constraint expression (without any context
declaration). This must be a boolean-valued expression
ParserException
- if the expression
fails to parsesetOperationContext(Object, Object)
CT createBodyCondition(String expression) throws ParserException
expression
- the constraint expression (without any context
declaration). Ordinarily, this is an expression of the same type
as the operation, specifying the value of the operation.
Alternatively, this may be a boolean-valued expression phrased like
a post-condition (according to the well-formedness rules of UML
constraints)
ParserException
- if the expression
fails to parsesetOperationContext(Object, Object)
CT createInitialValueExpression(String expression) throws ParserException
expression
- the initial value expression (without any context
declaration). This must conform to my context property type
ParserException
- if the expression
fails to parse
or is not valid for my context propertysetAttributeContext(Object, Object)
CT createDerivedValueExpression(String expression) throws ParserException
expression
- the derived value expression (without any context
declaration). This must conform to my context property type
ParserException
- if the expression
fails to parse
or is not valid for my context propertysetAttributeContext(Object, Object)
O defineOperation(String defExpression) throws ParserException
operation-name(parameters?) : type = expr
defExpression
- the definition expression (without any other context
declaration).
ParserException
- if the expression
fails to parseP defineAttribute(String defExpression) throws ParserException
attribute-name : type = expr
defExpression
- the definition expression (without any other context
declaration).
ParserException
- if the expression
fails to parseList<Choice> getSyntaxHelp(ConstraintKind constraintType, String txt)
constraintType
- the kind of constraint that is being composed,
or null
to indicate completions for a query expressiontxt
- a partial OCL expression for which to seek choices that
could be appended to it
Choice
s, possibly empty. The ordering of the
list may or may not indicate relative relevance or frequency of
a choiceDiagnostic getProblems()
null
if all was OK
|
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 |