Top Description Inners Fields Constructors Methods
org.springframework.expression.spel.ast

public abstract Class Operator

extends SpelNodeImpl
Class Inheritance
Known Direct Subclasses
org.springframework.expression.spel.ast.OperatorBetween, org.springframework.expression.spel.ast.OperatorInstanceof, org.springframework.expression.spel.ast.OperatorMatches, org.springframework.expression.spel.ast.OperatorPower, org.springframework.expression.spel.ast.OpGE, org.springframework.expression.spel.ast.OpInc, org.springframework.expression.spel.ast.OpLE, org.springframework.expression.spel.ast.OpLT, org.springframework.expression.spel.ast.OpMinus, org.springframework.expression.spel.ast.OpModulus, org.springframework.expression.spel.ast.OpMultiply, org.springframework.expression.spel.ast.OpNE, org.springframework.expression.spel.ast.OpOr, org.springframework.expression.spel.ast.OpPlus, org.springframework.expression.spel.ast.OpGT, org.springframework.expression.spel.ast.OpAnd, org.springframework.expression.spel.ast.OpDec, org.springframework.expression.spel.ast.OpDivide, org.springframework.expression.spel.ast.OpEQ
Imports
java.math.BigDecimal, .BigInteger, org.springframework.asm.Label, .MethodVisitor, org.springframework.expression.EvaluationContext, org.springframework.expression.spel.CodeFlow, org.springframework.lang.Nullable, org.springframework.util.NumberUtils, .ObjectUtils

Common supertype for operators that operate on either one or two operands. In the case of multiply or divide there would be two operands, but for unary plus or minus, there is only one.
Authors
Andy Clement, Juergen Hoeller, Giovanni Dall'Oglio Risso, Sam Brannen
Since
3.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class
Operator.DescriptorComparison

A descriptor comparison encapsulates the result of comparing descriptor for two operands and describes at what level they are compatible.

Field Summary

Modifier and TypeField and Description
protected String
private final String
protected String
Inherited from org.springframework.expression.spel.ast.SpelNodeImpl:
childrenexitTypeDescriptor

Constructor Summary

AccessConstructor and Description
public
Operator(String payload, int startPos, int endPos, SpelNodeImpl... operands)

Method Summary

Modifier and TypeMethod and Description
public static boolean
equalityCheck(EvaluationContext
the current evaluation context
context
,
Object
the left-hand operand value
left
,
Object
the right-hand operand value
right
)

Perform an equality check for the given operand values.

protected void
generateComparisonCode(MethodVisitor mv, CodeFlow cf, int compInstruction1, int compInstruction2)

Numeric comparison operators share very similar generated code, only differing in two comparison instructions.

public SpelNodeImpl
public final String
public SpelNodeImpl
protected boolean
public String
toStringAST()

Implements org.springframework.expression.spel.SpelNode.toStringAST.

String format for all operators is the same '(' [operand] [operator] [operand] ')'.
Inherited from org.springframework.expression.spel.ast.SpelNodeImpl:
generateCodegenerateCodeForArgumentgenerateCodeForArgumentsgetChildgetChildCountgetEndPositiongetExitDescriptorgetObjectClassgetStartPositiongetTypedValuegetValuegetValuegetValueInternalgetValueRefisCompilableisWritablenextChildIssetValuesetValueInternal

Field Detail

leftActualDescriptorback to summary
protected String leftActualDescriptor
Annotations
@Nullable
operatorNameback to summary
private final String operatorName
rightActualDescriptorback to summary
protected String rightActualDescriptor
Annotations
@Nullable

Constructor Detail

Operatorback to summary
public Operator(String payload, int startPos, int endPos, SpelNodeImpl... operands)

Method Detail

equalityCheckback to summary
public static boolean equalityCheck(EvaluationContext context, Object left, Object right)

Perform an equality check for the given operand values.

This method is not just used for reflective comparisons in subclasses but also from compiled expression code, which is why it needs to be declared as public static here.

Parameters
context:EvaluationContext

the current evaluation context

left:Object

the left-hand operand value

right:Object

the right-hand operand value

generateComparisonCodeback to summary
protected void generateComparisonCode(MethodVisitor mv, CodeFlow cf, int compInstruction1, int compInstruction2)

Numeric comparison operators share very similar generated code, only differing in two comparison instructions.

getLeftOperandback to summary
public SpelNodeImpl getLeftOperand()
getOperatorNameback to summary
public final String getOperatorName()
getRightOperandback to summary
public SpelNodeImpl getRightOperand()
isCompilableOperatorUsingNumericsback to summary
protected boolean isCompilableOperatorUsingNumerics()
toStringASTback to summary
public String toStringAST()

Implements org.springframework.expression.spel.SpelNode.toStringAST.

String format for all operators is the same '(' [operand] [operator] [operand] ')'.

Returns:String

Doc from org.springframework.expression.spel.SpelNode.toStringAST.

the string form

Annotations
@Override
org.springframework.expression.spel.ast back to summary

protected final Class Operator.DescriptorComparison

extends Object
Class Inheritance
  • java.lang.Object
  • org.springframework.expression.spel.ast.Operator.DescriptorComparison

A descriptor comparison encapsulates the result of comparing descriptor for two operands and describes at what level they are compatible.

Field Summary

Modifier and TypeField and Description
pack-priv final boolean
pack-priv final boolean
pack-priv final char
pack-priv static final Operator.DescriptorComparison
pack-priv static final Operator.DescriptorComparison

Constructor Summary

AccessConstructor and Description
private
DescriptorComparison(boolean areNumbers, boolean areCompatible, char compatibleType)

Method Summary

Modifier and TypeMethod and Description
public static Operator.DescriptorComparison

Returns:

a DescriptorComparison object indicating the type of compatibility, if any
checkNumericCompatibility
(String
the statically determinable left descriptor
leftDeclaredDescriptor
,
String
the statically determinable right descriptor
rightDeclaredDescriptor
,
String
the dynamic/runtime left object descriptor
leftActualDescriptor
,
String
the dynamic/runtime right object descriptor
rightActualDescriptor
)

Return an object that indicates whether the input descriptors are compatible.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

areCompatibleback to summary
pack-priv final boolean areCompatible
areNumbersback to summary
pack-priv final boolean areNumbers
compatibleTypeback to summary
pack-priv final char compatibleType
INCOMPATIBLE_NUMBERSback to summary
pack-priv static final Operator.DescriptorComparison INCOMPATIBLE_NUMBERS
NOT_NUMBERSback to summary
pack-priv static final Operator.DescriptorComparison NOT_NUMBERS

Constructor Detail

DescriptorComparisonback to summary
private DescriptorComparison(boolean areNumbers, boolean areCompatible, char compatibleType)

Method Detail

checkNumericCompatibilityback to summary
public static Operator.DescriptorComparison checkNumericCompatibility(String leftDeclaredDescriptor, String rightDeclaredDescriptor, String leftActualDescriptor, String rightActualDescriptor)

Return an object that indicates whether the input descriptors are compatible.

A declared descriptor is what could statically be determined (e.g. from looking at the return value of a property accessor method) whilst an actual descriptor is the type of an actual object that was returned, which may differ.

For generic types with unbound type variables, the declared descriptor discovered may be 'Object' but from the actual descriptor it is possible to observe that the objects are really numeric values (e.g. ints).

Parameters
leftDeclaredDescriptor:String

the statically determinable left descriptor

rightDeclaredDescriptor:String

the statically determinable right descriptor

leftActualDescriptor:String

the dynamic/runtime left object descriptor

rightActualDescriptor:String

the dynamic/runtime right object descriptor

Returns:Operator.DescriptorComparison

a DescriptorComparison object indicating the type of compatibility, if any