@Deprecated
public class Expression
extends java.lang.Object
implements java.io.Serializable
(a == b) ((a != b) || (b == c)) ((a >= 0) && (a < 10)) ((a != null) && (a == "some string")) (((!(a == b)) && (c < 10)) || (d == "cheese")) ((a + 5) == b) ((3 / 2) == 1) (((a + b) < c) && ((c / 2) > 5)) ((a % 2) == 0) ((a % 2) == 1)In the above, numbers and quoted strings represent their given values. Bare words (e.g. a, b, c, and d above) represent references to variables, which will be dereferenced from a hashtable when the expression is evaluated. For instance, in the third example above, when the expression is evaluated the key "a" will be used to query a hashtable (passed into the evaluation function). Let's say in the hashtable there is a field "5" stored under the key "a". So this expression will then actually evaluate to be ((5 >= 0) && (5 < 10)), which will be true. Data in the hashtable, and in quoted strings, will be converted to a number if possible, permitting typical numeric comparisons. In general the expressions parsed by this class should be pretty intuitive.
The keyword "null" can be used to check for the absence of a key in the hashtable, as in the fourth example above.
Operators permitted: ==, !=, <, >, <=, >=, !, &&, ||, +, -, *, /, %.
THIS CLASS IS DEPRECATED AND SHOULD NOT BE USED IN NEW DEVELOPMENT.
PLEASE USE GuardExpression
instead!
Modifier | Constructor and Description |
---|---|
protected |
Expression(java.util.List<java.lang.String> v)
Deprecated.
This constructor isn't for public consumption.
|
|
Expression(java.lang.Object operand1,
java.lang.String operator,
java.lang.Object operand2)
Deprecated.
|
|
Expression(java.lang.String s)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.Object |
convertOperand(java.lang.Object o,
java.util.Hashtable h)
Deprecated.
Converts an object to its Object type for evaluation
|
boolean |
equals(java.lang.Object other)
Deprecated.
|
java.lang.Object |
evaluate(java.util.Hashtable h)
Deprecated.
|
java.util.Enumeration |
findVariables()
Deprecated.
|
java.util.Hashtable |
generateLinearForm()
Deprecated.
Converts the expression to a more normal polynomial form,
consisting of a sum of a number of variable/coefficient
pairs.
|
java.lang.Object |
getOperand1()
Deprecated.
|
java.lang.Object |
getOperand2()
Deprecated.
|
java.lang.Object |
getOperator()
Deprecated.
|
java.util.Set |
getVariableSet()
Deprecated.
|
int |
hashCode()
Deprecated.
|
boolean |
isBooleanExpression()
Deprecated.
Determines if the expression is a boolean one (i.e.
|
boolean |
isComparisonExpression()
Deprecated.
Determines if the expression is a comparison one (i.e.
|
boolean |
isFalse(java.util.Hashtable h)
Deprecated.
|
boolean |
isMathematicalExpression()
Deprecated.
Determines if the expression is a mathematics one (i.e.
|
boolean |
isSatisfiable()
Deprecated.
Determines if the expression is satisfiable - that there
is some possible assignment of variables such that the
expression will as a whole be true.
|
boolean |
isTrue(java.util.Hashtable h)
Deprecated.
|
Expression |
negate()
Deprecated.
Performs fully recursive negation of a given Expression.
|
Expression |
negateOnce()
Deprecated.
Performs one negation step on a given Expression.
|
protected java.lang.String |
nextToken(java.util.List<java.lang.String> v)
Deprecated.
|
protected void |
parseExpression(java.util.List<java.lang.String> v)
Deprecated.
Parses the vector of tokens into a hierarchy of expressions.
|
void |
replaceComparisons(java.util.Hashtable h)
Deprecated.
Recursively replaces comparison subexpressions with arbitrary
variables ment to represent their actual outcome.
|
protected java.lang.Object |
simplifyOperand(java.lang.Object o)
Deprecated.
Converts an object to either a Double (string or numeric
constants) or a String (variable reference).
|
Expression |
splitOperand(java.lang.Object operand)
Deprecated.
Reads an operand object and returns an Expression representing that operand
|
java.lang.String |
toString()
Deprecated.
Stringifys it
|
java.lang.String |
toString(boolean indent)
Deprecated.
|
@Deprecated public Expression(java.lang.String s) throws java.text.ParseException
s
- The string version of the expressionjava.text.ParseException
protected Expression(java.util.List<java.lang.String> v) throws java.text.ParseException
java.text.ParseException
@Deprecated public Expression(java.lang.Object operand1, java.lang.String operator, java.lang.Object operand2)
@Deprecated public java.lang.Object getOperand1()
@Deprecated public java.lang.Object getOperand2()
@Deprecated public java.lang.Object getOperator()
@Deprecated public boolean isTrue(java.util.Hashtable h)
GuardExpression
and GuardExpression#isTrue(org.processmining.datapetrinets.expression.VariableProvider))
instead!
Use this function to check if the expression evaluates
to be true or not. The hashtable is a set of key/value
pairs where any bare word in the expression is used as
a key. When the expression is evaluated, it uses these
keys to find the appropriate value (if any) in the hashtable
and then perform the check with that value.
This function uses the evaluate method to calculate the value of the expression.
h
- A hashtable of references@Deprecated public boolean isFalse(java.util.Hashtable h)
GuardExpression
and GuardExpression#isFalse(org.processmining.datapetrinets.expression.VariableProvider))
instead!
Just like isTrue, except not.h
- A hashtable of referencesisTrue(java.util.Hashtable)
@Deprecated public java.lang.Object evaluate(java.util.Hashtable h)
GuardExpression
and GuardExpression#evaluate(org.processmining.datapetrinets.expression.VariableProvider))
instead!
This method performs the evaluation of the expression,
implementing binary and unary operator functions, and
recursively calling itself for sub-expressions.
This short ciruits ||s and &&s.
h
- A hashtable of referencesprotected java.lang.Object convertOperand(java.lang.Object o, java.util.Hashtable h)
o
- The operand to converth
- The hashtable of data to referenceprotected void parseExpression(java.util.List<java.lang.String> v) throws java.text.ParseException
v
- A vector of tokensjava.text.ParseException
protected java.lang.String nextToken(java.util.List<java.lang.String> v)
public java.util.Hashtable generateLinearForm()
All the items in the expression will be moved over to the LHS, so the RHS is effectively zero.
In this function, strings are considered constants, and will be converted to some Double form with reasonable uniqueness within the space.
If the expression cannot be reduced to this form, because of embedded boolean expressions or nonlinear expressions null will be returned. It will also return null for linear multiplications, i.e. (a * b) cannot be represented this way.
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
protected java.lang.Object simplifyOperand(java.lang.Object o)
o
- The operand to convertpublic boolean isSatisfiable()
public void replaceComparisons(java.util.Hashtable h)
h
- Send in an empty hashtable, it will contain the boolean
variable to replaced expression mapping on completion.@Deprecated public java.util.Enumeration findVariables()
GuardExpression
and getVariableSet()
instead!
Returns a list of the variables present in the expression.
Each variable is a String.public java.util.Set getVariableSet()
public boolean isBooleanExpression()
public boolean isComparisonExpression()
public boolean isMathematicalExpression()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(boolean indent)
public Expression negateOnce()
public Expression negate() throws java.text.ParseException
java.text.ParseException
public Expression splitOperand(java.lang.Object operand)