Expression class
Constructors
- Expression(String expression, {int powerOperatorPrecedence = Expression.operatorPrecedencePower})
- Creates a new expression instance from an expression string
Properties
-
functions
↔ Map<
String, ILazyFunction> -
All defined functions with name and implementation.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
-
operators
↔ Map<
String, ILazyOperator> -
All defined operators with name and implementation.
getter/setter pair
- powerOperatorPrecedence ↔ int
-
The precedence of the power (^) operator. Default is 40.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
variables
↔ Map<
String, LazyNumber?> -
All defined variables with name and value.
getter/setter pair
Methods
-
addFunc(
IFunc function) → IFunc - Adds a function to the list of supported functions
-
addLazyFunction(
ILazyFunction function) → ILazyFunction - Adds a lazy function function to the list of supported functions
-
addOperator<
T extends ILazyOperator> (T operator) → T - Adds an operator to the list of supported operators.
-
createLazyNumber(
Decimal? decimal) → LazyNumber - Construct a LazyNumber from a BigDecimal
-
eval(
) → Decimal? - Evaluates the expression.
-
getDeclaredFunctions(
) → Iterable< String> - Exposing declared functions.
-
getDeclaredOperators(
) → Iterable< String> - Exposing declared operators in the expression.
-
getDeclaredVariables(
) → Iterable< String> - Exposing declared variables in the expression.
-
getExpressionTokenizer(
) → Iterator< Token?> - Get an iterator for this expression, allows iterating over an expression token by token.
-
getRPN(
) → List< Token> - Cached access to the RPN notation of this expression, ensures only one calculation of the RPN per expression instance. If no cached instance exists, a new one will be created and put to the cache.
-
getUsedVariables(
) → List< String> - Returns a list of the variables in the expression.
-
isBoolean(
) → bool - Checks whether the expression is a boolean expression. An expression is considered a boolean expression, if the last operator or function is boolean. The IF function is handled special. If the third parameter is boolean, then the IF is also considered boolean, else non-boolean.
-
isNumber(
String st) → bool - Is the string a number?
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setDecimalVariable(
String variable, Decimal? value) → Expression - Sets a variable value.
-
setFirstVariableCharacters(
String chars) → Expression - Sets the characters other than letters and digits that are valid as the first character of a variable.
-
setLazyVariable(
String variable, LazyNumber? value) → Expression - Sets a variable value.
-
setStringVariable(
String variable, String value) → Expression - Sets a variable value.
-
setVariableCharacters(
String chars) → Expression - Sets the characters other than letters and digits that are valid as the second and subsequent characters of a variable.
-
toRPN(
) → String - Get a string representation of the RPN (Reverse Polish Notation) for this expression.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- e → Decimal
-
Definition of e: "Euler's number" as a constant, can be used in expressions as variable.
final
- missingParametersForOperator → String
-
Exception message for missing operators.
final
- pi → Decimal
-
Definition of PI as a constant, can be used in expressions as variable.
final
Constants
- operatorPrecedenceAdditive → const int
- Additive operators precedence: + and -
- operatorPrecedenceAnd → const int
- And operator precedence: &&
- operatorPrecedenceComparison → const int
- Comparative operators precedence: <,>,<=,>=
- operatorPrecedenceEquality → const int
- Equality operators precedence: =, ==, !=. <>
- operatorPrecedenceMultiplicative → const int
- Multiplicative operators precedence: *,/,%
- operatorPrecedenceOr → const int
- Or operator precedence: ||
- operatorPrecedencePower → const int
- Power operator precedence: ^
- operatorPrecedencePowerHigher → const int
- An optional higher power operator precedence. {@link ExpressionSettings}
- operatorPrecedenceUnary → const int
- Unary operators precedence: + and - as prefix