org.eclipse.ocl.parser
Class ValidationVisitor<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>

java.lang.Object
  extended by org.eclipse.ocl.parser.ValidationVisitor<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
All Implemented Interfaces:
Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>

public class ValidationVisitor<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
extends java.lang.Object
implements Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>

Checks the well-formedness rules for the expressions package


Constructor Summary
protected ValidationVisitor(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> environment)
          Initializes me to validate expressions in the specified environment.
 
Method Summary
static
<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>
getInstance(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> environment)
          Obtains an instance of the validation visitor that validates against the specified environment, which presumably was used in parsing the OCL in the first place.
protected  C getOCLType(java.lang.Object metaElement)
          Obtains the type of a meta-element, ensuring that the result is canonicalized with respect to the current environment (via its type resolver).
protected  java.lang.Boolean validatorError(java.lang.Object problemObject, java.lang.String problemMessage, java.lang.String problemContext)
          Pass a problemMessage generated for a problemObject at some validationContext to env.getErrorHandler().
 java.lang.Boolean visitAssociationClassCallExp(AssociationClassCallExp<C,P> ae)
          Callback for an AssociationClassCallExp visit.
 java.lang.Boolean visitBooleanLiteralExp(BooleanLiteralExp<C> bl)
          Callback for a BooleanLiteralExp visit.
 java.lang.Boolean visitCollectionItem(CollectionItem<C> item)
           
 java.lang.Boolean visitCollectionLiteralExp(CollectionLiteralExp<C> cl)
          Callback for a CollectionLiteralExp visit.
 java.lang.Boolean visitCollectionRange(CollectionRange<C> range)
           
 java.lang.Boolean visitConstraint(CT constraint)
          Applies well-formedness rules to constraints.
 java.lang.Boolean visitEnumLiteralExp(EnumLiteralExp<C,EL> el)
          Callback for an EnumLiteralExp visit.
 java.lang.Boolean visitExpressionInOCL(ExpressionInOCL<C,PM> expression)
           
 java.lang.Boolean visitIfExp(IfExp<C> i)
          Callback for an IfExp visit.
 java.lang.Boolean visitIntegerLiteralExp(IntegerLiteralExp<C> il)
          Callback for an IntegerLiteralExp visit.
 java.lang.Boolean visitInvalidLiteralExp(InvalidLiteralExp<C> il)
           
 java.lang.Boolean visitIterateExp(IterateExp<C,PM> ie)
          Callback for an IterateExp visit.
 java.lang.Boolean visitIteratorExp(IteratorExp<C,PM> ie)
          Callback for an IteratorExp visit.
 java.lang.Boolean visitLetExp(LetExp<C,PM> l)
          Callback for LetExp visit.
 java.lang.Boolean visitMessageExp(MessageExp<C,COA,SSA> m)
           
 java.lang.Boolean visitNullLiteralExp(NullLiteralExp<C> il)
           
 java.lang.Boolean visitOperationCallExp(OperationCallExp<C,O> oc)
          Callback for an OperationCallExp visit.
 java.lang.Boolean visitPropertyCallExp(PropertyCallExp<C,P> pc)
          Callback for an PropertyCallExp visit.
 java.lang.Boolean visitRealLiteralExp(RealLiteralExp<C> rl)
          Callback for a RealLiteralExp visit.
 java.lang.Boolean visitStateExp(StateExp<C,S> s)
           
 java.lang.Boolean visitStringLiteralExp(StringLiteralExp<C> sl)
          Callback for a StringLiteralExp visit.
 java.lang.Boolean visitTupleLiteralExp(TupleLiteralExp<C,P> tl)
          Callback for a TupleLiteralExp visit.
 java.lang.Boolean visitTupleLiteralPart(TupleLiteralPart<C,P> tp)
           
 java.lang.Boolean visitTypeExp(TypeExp<C> t)
          Callback for a TypeExp visit.
 java.lang.Boolean visitUnlimitedNaturalLiteralExp(UnlimitedNaturalLiteralExp<C> unl)
          Callback for an UnlimitedNaturalLiteralExp visit.
 java.lang.Boolean visitUnspecifiedValueExp(UnspecifiedValueExp<C> uv)
          Callback for an UnspecifiedValueExp visit.
 java.lang.Boolean visitVariable(Variable<C,PM> vd)
          Callback for a VariableDeclaration visit.
 java.lang.Boolean visitVariableExp(VariableExp<C,PM> v)
          Callback for a VariableExp visit.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidationVisitor

protected ValidationVisitor(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> environment)
Initializes me to validate expressions in the specified environment.

Parameters:
environment - the environment
Since:
1.2
Method Detail

getInstance

public static <PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT> getInstance(Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> environment)
Obtains an instance of the validation visitor that validates against the specified environment, which presumably was used in parsing the OCL in the first place.

Parameters:
environment - an OCL environment (must no be null)
Returns:
a validation visitor instance for the specified environment

validatorError

protected java.lang.Boolean validatorError(java.lang.Object problemObject,
                                           java.lang.String problemMessage,
                                           java.lang.String problemContext)
Pass a problemMessage generated for a problemObject at some validationContext to env.getErrorHandler().

Parameters:
problemObject - The object being validated, may be null if unknown
problemMessage - The problem with problemObject
validationContext - Optional context of the validator, may be null
Returns:
TRUE always, since a validation error has been reported.

visitOperationCallExp

public java.lang.Boolean visitOperationCallExp(OperationCallExp<C,O> oc)
Callback for an OperationCallExp visit. Well-formedness rule: All of the arguments must conform to the parameters of the referred operation. There must be exactly as many arguments as the referred operation has parameters.

Specified by:
visitOperationCallExp in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>
Parameters:
oc - the operation call expression
Returns:
Boolean -- true if validated

visitEnumLiteralExp

public java.lang.Boolean visitEnumLiteralExp(EnumLiteralExp<C,EL> el)
Callback for an EnumLiteralExp visit. Well-formedness rule: The type of an enum Literal expression is the type of the referred literal.

Specified by:
visitEnumLiteralExp in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>
Parameters:
el - the enumeration literal expresion
Returns:
Boolean -- true if validated

visitVariableExp

public java.lang.Boolean visitVariableExp(VariableExp<C,PM> v)
Callback for a VariableExp visit. Well-formedness rule: The type of a VariableExp is the type of the Variable to which it refers.

Specified by:
visitVariableExp in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>
Parameters:
v - the variable expression
Returns:
Boolean -- true if validated

visitPropertyCallExp

public java.lang.Boolean visitPropertyCallExp(PropertyCallExp<C,P> pc)
Callback for an PropertyCallExp visit. Well-formedness rule: The type of the PropertyCallExp is the type of the referred EStructuralFeature.

Specified by:
visitPropertyCallExp in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>
Parameters:
pc - the property call expression
Returns:
Boolean -- true if validated

visitAssociationClassCallExp

public java.lang.Boolean visitAssociationClassCallExp(AssociationClassCallExp<C,P> ae)
Callback for an AssociationClassCallExp visit. Well-formedness rules:

Specified by:
visitAssociationClassCallExp in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>
Parameters:
ae - the association end expression
Returns:
Boolean -- true if validated

visitVariable

public java.lang.Boolean visitVariable(Variable<C,PM> vd)
Callback for a VariableDeclaration visit. Well-formedness rule: The type of the initExpression must conform to the type of the declared variable.

Specified by:
visitVariable in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>
Parameters:
vd - -- variable declaration
Returns:
Boolean -- true if validated

visitIfExp

public java.lang.Boolean visitIfExp(IfExp<C> i)
Callback for an IfExp visit. Well-formedness Rule: The type of the condition must be Boolean. The type of the if expression is the common supertype of the then and else

Specified by:
visitIfExp in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>
Parameters:
i - - if expression
Returns:
Boolean -- true if validated

visitMessageExp

public java.lang.Boolean visitMessageExp(MessageExp<C,COA,SSA> m)
Description copied from interface: Visitor

Specified by:
visitMessageExp in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>

visitUnspecifiedValueExp

public java.lang.Boolean visitUnspecifiedValueExp(UnspecifiedValueExp<C> uv)
Callback for an UnspecifiedValueExp visit.

Specified by:
visitUnspecifiedValueExp in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>
Parameters:
uv - -- unspecified value expression
Returns:
Boolean -- true if validated

visitTypeExp

public java.lang.Boolean visitTypeExp(TypeExp<C> t)
Callback for a TypeExp visit.

Specified by:
visitTypeExp in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>

visitIntegerLiteralExp

public java.lang.Boolean visitIntegerLiteralExp(IntegerLiteralExp<C> il)
Callback for an IntegerLiteralExp visit. Well-formedness rule: The type of an integer Literal expression is the type Integer

Specified by:
visitIntegerLiteralExp in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>
Parameters:
il - - integer literal expression
Returns:
Boolean -- true if validated

visitUnlimitedNaturalLiteralExp

public java.lang.Boolean visitUnlimitedNaturalLiteralExp(UnlimitedNaturalLiteralExp<C> unl)
Callback for an UnlimitedNaturalLiteralExp visit. Well-formedness rule: The type of an unlimited natural Literal expression is the type UnlimitedNatural

Specified by:
visitUnlimitedNaturalLiteralExp in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>
Parameters:
unl - - unlimited literal expression
Returns:
Boolean -- true if validated

visitRealLiteralExp

public java.lang.Boolean visitRealLiteralExp(RealLiteralExp<C> rl)
Callback for a RealLiteralExp visit. Well-formedness rule: The type of a real literal expression is the type Real.

Specified by:
visitRealLiteralExp in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>
Parameters:
rl - -- real literal expression
Returns:
Boolean -- true if validated

visitStringLiteralExp

public java.lang.Boolean visitStringLiteralExp(StringLiteralExp<C> sl)
Callback for a StringLiteralExp visit. Well-formedness rule: The type of a string literal expression is the type of the string.

Specified by:
visitStringLiteralExp in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>
Parameters:
sl - -- string literal expression
Returns:
Boolean -- true if validated

visitBooleanLiteralExp

public java.lang.Boolean visitBooleanLiteralExp(BooleanLiteralExp<C> bl)
Callback for a BooleanLiteralExp visit. Well-formedness rule: The type of a Boolean Literal expression is the type of the boolean.

Specified by:
visitBooleanLiteralExp in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>
Parameters:
bl - - boolean literal expression
Returns:
Boolean - true if validated

visitLetExp

public java.lang.Boolean visitLetExp(LetExp<C,PM> l)
Callback for LetExp visit. Well-formedness rule: The type of the Let expression is the type of the in expression.

Specified by:
visitLetExp in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>
Parameters:
l - -- let expression
Returns:
Boolean -- true if validated

visitIterateExp

public java.lang.Boolean visitIterateExp(IterateExp<C,PM> ie)
Callback for an IterateExp visit. *Well-formedness rule: The type of the iterate is the type of the result variable. The type of the body expression must conform to the declared type of the result variable. *A result variable must have an init expression. *The type of a source expression must be a collection. *The loop variable has no init expression. *The type of the iterator variable must be the type of the elements of the *source collection.

Specified by:
visitIterateExp in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>
Parameters:
ie - - iterate expression
Returns:
Boolean -- true if validated

visitIteratorExp

public java.lang.Boolean visitIteratorExp(IteratorExp<C,PM> ie)
Callback for an IteratorExp visit. Well-formedness rule: If the iterator is "forall", "isUnique", "any", "one", or "exists", the type of the iterator must be Boolean. The result type of the collect operation on a sequence type is a sequence; the result type of collect on any other type is a bag. The select and reject iterators have the same type as its source. They type of the body of the select, reject, forall, exists must be boolean. The type of a source expression must be a collection. The loop variable has no init expression. The type of the iterator variable must be the type of the elements of the source collection.

Specified by:
visitIteratorExp in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>
Parameters:
ie - -- iterator expression
Returns:
Boolean -- true if validated

visitCollectionLiteralExp

public java.lang.Boolean visitCollectionLiteralExp(CollectionLiteralExp<C> cl)
Callback for a CollectionLiteralExp visit. Well-formedness rule: The type of a collection literal expression is determined by the collection kind selection, and the common supertype of all elements. The empty collection has a Classifier as element type.

Specified by:
visitCollectionLiteralExp in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>
Parameters:
cl - -- collection literal expression
Returns:
Boolean -- true if validated

visitCollectionItem

public java.lang.Boolean visitCollectionItem(CollectionItem<C> item)
Description copied from interface: Visitor

Specified by:
visitCollectionItem in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>

visitCollectionRange

public java.lang.Boolean visitCollectionRange(CollectionRange<C> range)
Description copied from interface: Visitor

Specified by:
visitCollectionRange in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>

visitTupleLiteralExp

public java.lang.Boolean visitTupleLiteralExp(TupleLiteralExp<C,P> tl)
Callback for a TupleLiteralExp visit. Well-formedness rule: The type of a tuple literal is a TupleType the specified parts All tuple literal expression parts must have unique names. The type of each attribute in a tuple literal part must match the type of the initialization expression.

Specified by:
visitTupleLiteralExp in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>
Parameters:
tl - tuple literal expression
Returns:
Boolean

visitTupleLiteralPart

public java.lang.Boolean visitTupleLiteralPart(TupleLiteralPart<C,P> tp)
Description copied from interface: Visitor

Specified by:
visitTupleLiteralPart in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>

visitStateExp

public java.lang.Boolean visitStateExp(StateExp<C,S> s)
Description copied from interface: Visitor

Specified by:
visitStateExp in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>

visitInvalidLiteralExp

public java.lang.Boolean visitInvalidLiteralExp(InvalidLiteralExp<C> il)
Description copied from interface: Visitor

Specified by:
visitInvalidLiteralExp in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>

visitNullLiteralExp

public java.lang.Boolean visitNullLiteralExp(NullLiteralExp<C> il)
Description copied from interface: Visitor

Specified by:
visitNullLiteralExp in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>

visitExpressionInOCL

public java.lang.Boolean visitExpressionInOCL(ExpressionInOCL<C,PM> expression)
Description copied from interface: Visitor

Specified by:
visitExpressionInOCL in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>

visitConstraint

public java.lang.Boolean visitConstraint(CT constraint)
Applies well-formedness rules to constraints.

Specified by:
visitConstraint in interface Visitor<java.lang.Boolean,C,O,P,EL,PM,S,COA,SSA,CT>
Parameters:
constraint - the constraint to validate

getOCLType

protected C getOCLType(java.lang.Object metaElement)
Obtains the type of a meta-element, ensuring that the result is canonicalized with respect to the current environment (via its type resolver).

Parameters:
metaElement - a typed meta-element
Returns:
the OCL type corresponding to the element's type
Since:
1.2
See Also:
UMLReflection.getOCLType(Object)

Copyright 2002, 2007 IBM Corporation and others.
All Rights Reserved.