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

public Class Elvis

extends SpelNodeImpl
Class Inheritance
Imports
org.springframework.asm.Label, .MethodVisitor, org.springframework.expression.EvaluationException, .TypedValue, org.springframework.expression.spel.CodeFlow, .ExpressionState, org.springframework.util.Assert, .ObjectUtils

Represents the Elvis operator ?:. For an expression a?:b if a is neither null nor an empty String, the value of the expression is a. If a is null or the empty String, then the value of the expression is b.
Authors
Andy Clement, Juergen Hoeller, Sam Brannen
Since
3.0

Field Summary

Inherited from org.springframework.expression.spel.ast.SpelNodeImpl:
childrenexitTypeDescriptor

Constructor Summary

AccessConstructor and Description
public
Elvis(int startPos, int endPos, SpelNodeImpl... args)

Method Summary

Modifier and TypeMethod and Description
private void
public void
generateCode(MethodVisitor
the ASM MethodVisitor into which code should be generated
mv
,
CodeFlow
a context object with info about what is on the stack
cf
)

Overrides org.springframework.expression.spel.ast.SpelNodeImpl.generateCode.

Generate the bytecode for this node into the supplied visitor.
public TypedValue
getValueInternal(ExpressionState
the expression state
state
)

Implements abstract org.springframework.expression.spel.ast.SpelNodeImpl.getValueInternal.

Evaluate the condition and if neither null nor an empty String, return it.
public boolean
isCompilable()

Overrides org.springframework.expression.spel.ast.SpelNodeImpl.isCompilable.

Check whether a node can be compiled to bytecode.
public String
toStringAST()

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

Return the string form of this AST node.
Inherited from org.springframework.expression.spel.ast.SpelNodeImpl:
generateCodeForArgumentgenerateCodeForArgumentsgetChildgetChildCountgetEndPositiongetExitDescriptorgetObjectClassgetStartPositiongetTypedValuegetValuegetValuegetValueRefisWritablenextChildIssetValuesetValueInternal

Constructor Detail

Elvisback to summary
public Elvis(int startPos, int endPos, SpelNodeImpl... args)

Method Detail

computeExitTypeDescriptorback to summary
private void computeExitTypeDescriptor()
generateCodeback to summary
public void generateCode(MethodVisitor mv, CodeFlow cf)

Overrides org.springframework.expression.spel.ast.SpelNodeImpl.generateCode.

Doc from org.springframework.expression.spel.ast.SpelNodeImpl.generateCode.

Generate the bytecode for this node into the supplied visitor. Context info about the current expression being compiled is available in the codeflow object, e.g. including information about the type of the object currently on the stack.

Parameters
mv:MethodVisitor

the ASM MethodVisitor into which code should be generated

cf:CodeFlow

a context object with info about what is on the stack

Annotations
@Override
getValueInternalback to summary
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException

Implements abstract org.springframework.expression.spel.ast.SpelNodeImpl.getValueInternal.

Evaluate the condition and if neither null nor an empty String, return it. If it is null or an empty String, return the other value.

Parameters
state:ExpressionState

the expression state

Annotations
@Override
Exceptions
EvaluationException:
if the condition does not evaluate correctly to a boolean or there is a problem executing the chosen alternative
isCompilableback to summary
public boolean isCompilable()

Overrides org.springframework.expression.spel.ast.SpelNodeImpl.isCompilable.

Doc from org.springframework.expression.spel.ast.SpelNodeImpl.isCompilable.

Check whether a node can be compiled to bytecode. The reasoning in each node may be different but will typically involve checking whether the exit type descriptor of the node is known and any relevant child nodes are compilable.

Returns:boolean

true if this node can be compiled to bytecode

Annotations
@Override
toStringASTback to summary
public String toStringAST()

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

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

Return the string form of this AST node.

Returns:String

the string form

Annotations
@Override