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 java.lang.Object implements IConfiguration
Some basic functionality required by the evaluators without exposing theEvaluationVisitor.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Localelocale
-
Constructor Summary
Constructors Constructor Description EvaluationContext()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddErrorMessage(java.lang.String message, int code)Adds an evaluation error message.voidaddErrorMessage(java.lang.String message, IDecisionVariable variable, int code)Adds an evaluation error message.voidaddErrorMessage(java.lang.Throwable throwable)Adds an evaluation error message based on a throwable.abstract voidaddMessage(EvaluationVisitor.Message message)Adds an evaluation message.abstract booleanallowAssignValues()Returns whether values shall be assigned, i.e., the configuration may be changed.abstract booleanallowPropagation()Returns whether the expression to be evaluated is a propagation.(package private) voidclear()Clears this instance for reuse.abstract IAssignmentStategetAssignmentState()Returns the global (target) assignment state for the actual evaluation.java.text.CollatorgetCollator()Returns the collator corresponding to the actual locale of this context.ValuegetDereferencedValue(Value value)Dereferences a value within this context.java.util.LocalegetLocale()Returns the actual locale for evaluation.abstract IAssignmentStategetTargetState(IDecisionVariable variable)Returns the target state of the evaluation forvariable.abstract voidissueWarning()Indicates that the evaluation of this constraint shall lead to a warning.abstract voidnotifyChangeListener(IDecisionVariable variable, Value oldValue, IAssignmentState oldState, IValueChangeListener.ChangeKind kind)Notifies the change listener, i.e., the value ofvariablehas changed.voidsetLocale(java.util.Locale locale)Changes the locale for evaluation.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.ssehub.easy.varModel.confModel.IConfiguration
getAllInstances, getDecision
-
-
-
-
Method Detail
-
clear
void clear()
Clears this instance for reuse.
-
getLocale
public java.util.Locale getLocale()
Returns the actual locale for evaluation.- Returns:
- the locale
-
setLocale
public void setLocale(java.util.Locale locale)
Changes the locale for evaluation.- Parameters:
locale- the new locale, ignored if null
-
getCollator
public java.text.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:
trueif values shall be assigned,falseelse
-
notifyChangeListener
public abstract void notifyChangeListener(IDecisionVariable variable, Value oldValue, IAssignmentState oldState, IValueChangeListener.ChangeKind kind)
Notifies the change listener, i.e., the value ofvariablehas changed.- Parameters:
variable- the changed variableoldValue- the value ofvariablebefore the change (may be null)oldState- the old state ofvariablebefore the changekind- 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 forvariable.- 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(java.lang.String message, int code)Adds an evaluation error message.- Parameters:
message- the message to be addedcode- the error code
-
addErrorMessage
public void addErrorMessage(java.lang.String message, IDecisionVariable variable, int code)Adds an evaluation error message.- Parameters:
message- the message to be addedvariable- OptionalIDecisionVariablewhich caused the errorcode- the error code
-
addErrorMessage
public void addErrorMessage(java.lang.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:
trueif it is a propagation, i.e. propagation shall be allowed,falseelse
-
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 fromgetTargetState(IDecisionVariable).- Returns:
- the assignment state
-
-