Class EvaluationContext

java.lang.Object
net.ssehub.easy.varModel.cstEvaluation.EvaluationContext
All Implemented Interfaces:
IConfiguration
Direct Known Subclasses:
EvaluationVisitor.EvaluationContextImpl

public abstract class EvaluationContext extends Object implements IConfiguration
Some basic functionality required by the evaluators without exposing the EvaluationVisitor.
Author:
Holger Eichelberger
  • Field Details

    • locale

      private Locale locale
  • Constructor Details

    • EvaluationContext

      public EvaluationContext()
  • Method Details

    • clear

      void clear()
      Clears this instance for reuse.
    • getLocale

      public Locale getLocale()
      Returns the actual locale for evaluation.
      Returns:
      the locale
    • setLocale

      public void setLocale(Locale locale)
      Changes the locale for evaluation.
      Parameters:
      locale - the new locale, ignored if null
    • getCollator

      public Collator getCollator()
      Returns the collator corresponding to the actual locale of this context.
      Returns:
      the collator
    • allowAssignValues

      public abstract boolean allowAssignValues()
      Returns whether values shall be assigned, i.e., the configuration may be changed.
      Returns:
      true if values shall be assigned, false else
    • notifyChangeListener

      public abstract void notifyChangeListener(IDecisionVariable variable, Value oldValue, IAssignmentState oldState, IValueChangeListener.ChangeKind kind)
      Notifies the change listener, i.e., the value of variable has changed.
      Parameters:
      variable - the changed variable
      oldValue - the value of variable before the change (may be null)
      oldState - the old state of variable before the change
      kind - the change kind
    • addMessage

      public abstract void addMessage(EvaluationVisitor.Message message)
      Adds an evaluation message.
      Parameters:
      message - the message to be added
    • getTargetState

      public abstract IAssignmentState getTargetState(IDecisionVariable variable)
      Returns the target state of the evaluation for variable.
      Parameters:
      variable - the variable to return the target state for (do not modify!!!)
      Returns:
      the target state (may be null if the actual value cannot be assigned do to a state conflict)
    • addErrorMessage

      public void addErrorMessage(String message, int code)
      Adds an evaluation error message.
      Parameters:
      message - the message to be added
      code - the error code
    • addErrorMessage

      public void addErrorMessage(String message, IDecisionVariable variable, int code)
      Adds an evaluation error message.
      Parameters:
      message - the message to be added
      variable - Optional IDecisionVariable which caused the error
      code - the error code
    • addErrorMessage

      public void addErrorMessage(Throwable throwable)
      Adds an evaluation error message based on a throwable.
      Parameters:
      throwable - the throwable carrying the message
    • issueWarning

      public abstract void issueWarning()
      Indicates that the evaluation of this constraint shall lead to a warning.
    • allowPropagation

      public abstract boolean allowPropagation()
      Returns whether the expression to be evaluated is a propagation.
      Returns:
      true if it is a propagation, i.e. propagation shall be allowed, false else
    • getDereferencedValue

      public Value getDereferencedValue(Value value)
      Dereferences a value within this context.
      Parameters:
      value - the value to dereference
      Returns:
      the dereferenced value (may be null if undefined)
    • getAssignmentState

      public abstract IAssignmentState getAssignmentState()
      Returns the global (target) assignment state for the actual evaluation. This may differ from getTargetState(IDecisionVariable).
      Returns:
      the assignment state