|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectlt.monarch.math.AbstractFormulaParser
lt.monarch.math.LogicalParser
public class LogicalParser extends AbstractFormulaParser
Logical parser, which parses boolean expressions. You must supply the string, which would return true or false result. e.g. "x0>5" or "(sin(x0) <= 1) && (sin(x0) >= -1). Notice that if you use conjunction or union for expressions which are not trivial (true, false values), it is better to use the brackets to specify the boundaries, which parts must be united or conjuncted. Any formula, which is possible to parse with FormulaParser, can be used in this expression. Also boolean values "true", "false" are allowed too. If you prefer you can use ".T",".F" instead of true, false. Allowed operations in the expression are:
&& - conjunction operator
|| - union operator
## - xor operator
! - negation operator
<, >, ==, !=, <=, >= are comparison operators
(,) - brackets can be used to specify the boundaries of union, negation and etc. Be sure to match the number of brackets. All comparison operations has a higher priority over &&, || and ## operations. So if you want those operations to be performed prior to comparison operations, you must use brackets. Any comparison operation, except == and !=, will return false value. Null values can be compared with == and != operators,e.g "x0==null"
| Modifier and Type | Class and Description |
|---|
| Nested classes/interfaces inherited from class lt.monarch.math.AbstractFormulaParser |
|---|
AbstractFormulaParser.AbstractNode |
| Modifier and Type | Field and Description |
|---|
| Fields inherited from class lt.monarch.math.AbstractFormulaParser |
|---|
dataModel, nodeHash |
| Constructor and Description |
|---|
LogicalParser(java.lang.String expression)
Logical parser constructor. |
| Modifier and Type | Method and Description |
|---|---|
void |
dispose()
Disposes the resources used by the class |
boolean |
eval()
Evaluates the logical expression |
boolean |
eval(double value)
Evaluates the logical expression |
boolean |
eval(java.lang.Double[] variables)
Evaluates the logical expression |
protected void |
finalize()
|
void |
setDataModel(DataModel dataModel)
Sets the dataModel object |
void |
setVariable(java.lang.String variableName,
int value)
Sets variable value |
| Methods inherited from class lt.monarch.math.AbstractFormulaParser |
|---|
getDataModel |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LogicalParser(java.lang.String expression)
throws java.lang.Exception
expression - logical expressionjava.lang.Exception - throws exception if any error occurs, when building evaluation tree or
tokenizing the formula.| Method Detail |
|---|
public void setDataModel(DataModel dataModel)
AbstractFormulaParser
setDataModel in class AbstractFormulaParserdataModel - the dataModel object
public void setVariable(java.lang.String variableName,
int value)
variableName - variable name. Possible names: index, row, columnvalue - variable valuepublic boolean eval()
public boolean eval(double value)
value - value to set for x0 variablepublic boolean eval(java.lang.Double[] variables)
variables - array of x values. The 0th element of array corresponds to x0 variable, 1st
to x1 and etc.public void dispose()
AbstractFormulaParser
dispose in class AbstractFormulaParser
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||