org.eclipse.ocl.examples.pivot.utilities
Class ConstraintEvaluator<T>

java.lang.Object
  extended by org.eclipse.ocl.examples.pivot.utilities.ConstraintEvaluator<T>
Type Parameters:
T - the result type
Direct Known Subclasses:
AbstractPivotConstraintLocator.AbstractConstraintLocator, OCLValidationDelegate.CheckingConstraintEvaluator, UMLOCLEValidator.ConstraintEvaluatorWithDiagnostics, UMLOCLEValidator.ConstraintEvaluatorWithoutDiagnostics

public abstract class ConstraintEvaluator<T>
extends java.lang.Object

ConstraintEvaluator provides an abstract framework for evaluation of a constraint with call backs to handle the alternative success, failure, invalid and exception outcomes and return an appropriate value of T.


Field Summary
protected  ExpressionInOCL expression
           
 
Constructor Summary
ConstraintEvaluator(ExpressionInOCL expression)
          Construct an helper for the evaluation of an expression
 
Method Summary
 T evaluate(EvaluationVisitor evaluationVisitor)
          Use the evaluationVisitor to execute my expression on the objects within the evaluationVisitor's evaluationEnvironment, invoking one of handleSuccessResult, handleFailureResult, handleInvalidResult or handleExceptionResult to provide the return value.
protected  java.lang.String getConstraintName()
           
protected  java.lang.String getConstraintResultMessage(java.lang.Object result)
          Return the message of result, which is null unless result is a Tuple with a more informative severity part.
protected  int getConstraintResultSeverity(java.lang.Object result)
          Return the org.eclipse.emf.common.util.Diagnostic severity of result, which is ERROR unless result is a Tuple with a more informative severity part.
protected  boolean getConstraintResultStatus(java.lang.Object result)
          Return true if result represents a successful constraint evaluation result.
protected  java.lang.String getConstraintTypeName()
           
protected abstract  java.lang.String getObjectLabel()
          Call-back to provide a description of the context object for use in a diagnostic.
protected abstract  T handleExceptionResult(java.lang.Throwable e)
          Call-back to return the appropriate response for an evaluation that was terminated by an exception.
protected abstract  T handleFailureResult(java.lang.Object result)
          Call-back to return the appropriate response for a failed evaluation.
protected abstract  T handleInvalidExpression(java.lang.String message)
          Call-back to return the appropriate response for an unsuccessful parse of the expression.
protected abstract  T handleInvalidResult(InvalidValueException e)
          Call-back to return the appropriate response for an unsuccessful evaluation with an invalid result.
protected abstract  T handleSuccessResult()
          Call-back to return the appropriate response for a successful evaluation.
protected  boolean isBooleanConstraint()
          Return true if the constraint has a Boolean result type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

expression

@NonNull
protected final ExpressionInOCL expression
Constructor Detail

ConstraintEvaluator

public ConstraintEvaluator(@NonNull
                           ExpressionInOCL expression)
Construct an helper for the evaluation of an expression

Method Detail

evaluate

public T evaluate(@NonNull
                  EvaluationVisitor evaluationVisitor)
Use the evaluationVisitor to execute my expression on the objects within the evaluationVisitor's evaluationEnvironment, invoking one of handleSuccessResult, handleFailureResult, handleInvalidResult or handleExceptionResult to provide the return value.


getConstraintName

protected java.lang.String getConstraintName()

getConstraintResultMessage

@NonNull
protected java.lang.String getConstraintResultMessage(@Nullable
                                                              java.lang.Object result)
Return the message of result, which is null unless result is a Tuple with a more informative severity part.


getConstraintResultSeverity

protected int getConstraintResultSeverity(@Nullable
                                          java.lang.Object result)
Return the org.eclipse.emf.common.util.Diagnostic severity of result, which is ERROR unless result is a Tuple with a more informative severity part.


getConstraintResultStatus

protected boolean getConstraintResultStatus(@Nullable
                                            java.lang.Object result)
Return true if result represents a successful constraint evaluation result. Anything else leads to a false return (no null or exception).


getConstraintTypeName

protected java.lang.String getConstraintTypeName()

getObjectLabel

protected abstract java.lang.String getObjectLabel()
Call-back to provide a description of the context object for use in a diagnostic.


handleExceptionResult

protected abstract T handleExceptionResult(@NonNull
                                           java.lang.Throwable e)
Call-back to return the appropriate response for an evaluation that was terminated by an exception.


handleFailureResult

protected abstract T handleFailureResult(@Nullable
                                         java.lang.Object result)
Call-back to return the appropriate response for a failed evaluation.


handleInvalidExpression

protected abstract T handleInvalidExpression(@NonNull
                                             java.lang.String message)
Call-back to return the appropriate response for an unsuccessful parse of the expression.


handleInvalidResult

protected abstract T handleInvalidResult(@NonNull
                                         InvalidValueException e)
Call-back to return the appropriate response for an unsuccessful evaluation with an invalid result.


handleSuccessResult

protected abstract T handleSuccessResult()
Call-back to return the appropriate response for a successful evaluation.


isBooleanConstraint

protected boolean isBooleanConstraint()
Return true if the constraint has a Boolean result type.