SpelOperations class abstract final

The operators of SpEL as plain functions: what an expression computes for /, ==, <, + on text, and and the like, apart from the tree that holds the operands.

The interpreter calls them for every operator, and so does the code the generator writes when it compiles an expression to Dart, so both give the same answer (7 / 2 is 3, 1 == 1.0, null < 1, 'a' + null is a and the text null). Applications do not call them; they appear in generated code. A function throws the SpelEvaluationException the interpreter reports, without the expression and position the interpreter adds to it.

// What the compiled form of `#a / #b` and `#a == #b` runs.
SpelOperations.divideInts(7, 2); // 3
SpelOperations.equals(1, 1.0); // true
SpelOperations.compare(null, 1) < 0; // true
SpelOperations.concat('n=', 1); // n=1

Spring (Java):

// The compiler mode of SpelExpression generates bytecode for them
// (OpDivide, OpEQ, OpLT, OpPlus, ...).

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

compare(Object? l, Object? r, [TypeComparator comparator = const StandardTypeComparator()]) → int
Negative, zero or positive as l is less than, equal to or greater than r, for <, <=, > and >=: null comes before everything, numbers compare by value, and values that cannot be ordered fail with SpelMessage.notComparable. comparator decides, the standard one by default.
concat(Object? l, Object? r, {bool leftReal = false, bool rightReal = false, TypeConverter? typeConverter}) → String
l + r when one side is a string: the other side is turned into text with text (leftReal and rightReal as in numeric).
divide(num l, num r, {bool leftReal = false, bool rightReal = false}) → num
l / r for numbers of which it is not known whether both are ints (see numeric, also for leftReal and rightReal).
divideInts(int l, int r) → int
l / r for two ints: truncating, and an UnsupportedError when r is zero.
doubleToString(double value) → String
Java's Double.toString of value, what toString() of a real number gives: 2.5, and 7.0 also where an integral double is an int at run time (the web, where Dart prints 7).
equals(Object? l, Object? r, {TypeComparator comparator = const StandardTypeComparator(), bool isRealElement(Object collection, Object? key, Object? value)?}) → bool
The == of SpEL, also used by !=: numbers are equal by value (1 == 1.0), collections deeply (lists in order, sets and maps by content, with numbers inside compared like Java's equals, so {2.0} == {2} is false), other values by == or, for comparable values of the same type, compareTo == 0, like Spring.
join(String l, String r) → String
l followed by r, failing with SpelMessage.maxConcatenatedStringLengthExceeded beyond SpelLimits.maxConcatenatedStringLength characters.
listElement<E>(List<E> list, int index) → E
The element at index of list, failing with SpelMessage.collectionIndexOutOfBounds outside it (also for a negative index), as list[index] does.
modulus(num l, num r, {bool leftReal = false, bool rightReal = false}) → num
l % r for numbers of which it is not known whether both are ints (see numeric).
modulusInts(int l, int r) → int
l % r for two ints: the sign of l, an UnsupportedError when r is zero.
modulusReals(num l, num r) → double
l % r when an operand is a real number: a double.
numeric(Operation operation, num l, num r, {bool leftReal = false, bool rightReal = false}) → num
Applies the arithmetic operation to two numbers.
power(num l, num r, {bool leftReal = false, bool rightReal = false}) → num
l ^ r for numbers of which it is not known whether both are ints (see numeric).
powerInts(int l, int r) → int
l ^ r for two ints: the power truncated to an int (or a long).
powerReals(num l, num r) → double
l ^ r when an operand is a real number: a double.
stringElement(String text, int index) → String
The character at index of text, failing with SpelMessage.stringIndexOutOfBounds outside it, as 'text'[index] does.
text(Object? value, {bool real = false, TypeConverter? typeConverter}) → String
The text of value as the other side of a + on a string: null is 'null', a real number that is an int at run time (real) is Java's 7.0, anything else is converted by typeConverter (a list becomes 1,2) and printed with toString when it cannot be.
toBool(Object? value, [TypeConverter? typeConverter]) → bool
value as a bool for and, or, ! and the condition of ? :: a bool as it is, anything typeConverter can turn into one ('true') converted; null and other values fail with SpelMessage.typeConversionError.