public class BooleanExpression extends Object
Constructor and Description |
---|
BooleanExpression(String s)
Given a boolean expression as a string, parses it into a
BooleanExpression object that can manipulate and evaluate
it.
|
Modifier and Type | Method and Description |
---|---|
Boolean |
evaluate(Map<String,Boolean> assignments)
Returns true if the given assignments force this boolean
expression to be true, false if they force it to be false, and
null if it could be either true or false.
|
Set<String> |
getVariables()
Returns a set of the variables in this boolean expression.
|
boolean |
isAnd()
Returns true if the top level of this boolean expression
is an and and false otherwise.
|
boolean |
isNot()
Returns true if the top level of this boolean expression
is a not and false otherwise.
|
boolean |
isOr()
Returns true if the top level of this boolean expression
is an or and false otherwise.
|
boolean |
isVariable()
Returns true if this boolean expression is a variable
and false otherwise.
|
String |
toString()
Returns a string representation of this boolean expression.
|
public BooleanExpression(String s)
s
- A string representation of the expression to create.public boolean isVariable()
public boolean isOr()
public boolean isAnd()
public boolean isNot()
public String toString()
public Set<String> getVariables()
public Boolean evaluate(Map<String,Boolean> assignments)
assignments
- A (partial) map from variables to truth values.