public class BooleanExpression
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
BooleanExpression.BadSyntaxException |
static class |
BooleanExpression.BooleanExpressionException |
static class |
BooleanExpression.SemanticWarning |
static class |
BooleanExpression.SemanticWarningType |
static class |
BooleanExpression.SyntaxError |
static class |
BooleanExpression.Value |
Modifier and Type | Field and Description |
---|---|
static char |
CONJUNCTION_OPERATOR |
static char |
DISJUNCTION_OPERATOR |
static char |
NEGATION_OPERATOR |
Constructor and Description |
---|
BooleanExpression(java.lang.String expression) |
Modifier and Type | Method and Description |
---|---|
BooleanExpression.Value |
evaluate(java.util.Map<java.lang.String,BooleanExpression.Value> variableValues)
Evaluates the expression with the provided variable values.
|
static boolean |
fastImplicationCheck(BooleanExpression antecedent,
BooleanExpression consequent)
Performs fast check whether "antecedent -> consequent" evaluates to TRUE.
|
int |
getLiteralsCount() |
java.util.List<BooleanExpression.SemanticWarning> |
getSemanticWarnings() |
BooleanExpression.BadSyntaxException |
getSyntaxException() |
java.util.Set<java.lang.String> |
getVariables()
Returns the set of variables used is this expression
|
boolean |
hasErrors(boolean treatWarningsAsErrors) |
public static final char CONJUNCTION_OPERATOR
public static final char DISJUNCTION_OPERATOR
public static final char NEGATION_OPERATOR
public BooleanExpression(java.lang.String expression)
expression
- The expression string in disjunctive normal formpublic BooleanExpression.Value evaluate(java.util.Map<java.lang.String,BooleanExpression.Value> variableValues) throws BooleanExpression.BadSyntaxException
getVariables()
), there is no value in the variableValues map
(or the value is null), the value is considered BooleanExpression.Value.UNKNOWN
. In that case, the result may also be BooleanExpression.Value.UNKNOWN
-
meaning that currently we cannot evaluate the expression to neither BooleanExpression.Value.TRUE
or BooleanExpression.Value.FALSE
.
But it is not necessary BooleanExpression.Value.UNKNOWN
- the available values may still be enough to return a definitive resultvariableValues
- The keys are variable names, the values are the respective boolean BooleanExpression.Value
sBooleanExpression.BadSyntaxException
- in case of error in the expression syntaxpublic static boolean fastImplicationCheck(BooleanExpression antecedent, BooleanExpression consequent) throws BooleanExpression.BadSyntaxException
antecedent
- The antecedent of the conditionalconsequent
- The consequent of the conditionalBooleanExpression.BadSyntaxException
- in case of error in the expressions syntaxpublic java.util.Set<java.lang.String> getVariables()
public int getLiteralsCount()
public boolean hasErrors(boolean treatWarningsAsErrors)
public BooleanExpression.BadSyntaxException getSyntaxException()
public java.util.List<BooleanExpression.SemanticWarning> getSemanticWarnings()