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

public Class ConstructorReference

extends SpelNodeImpl
Class Inheritance
Imports
java.lang.reflect.Array, .Constructor, .InvocationTargetException, .Modifier, java.util.ArrayList, .List, .StringJoiner, org.springframework.asm.MethodVisitor, org.springframework.core.convert.TypeDescriptor, org.springframework.expression.AccessException, .ConstructorExecutor, .ConstructorResolver, .EvaluationContext, .EvaluationException, .TypeConverter, .TypedValue, org.springframework.expression.common.ExpressionUtils, org.springframework.expression.spel.CodeFlow, .ExpressionState, .SpelEvaluationException, .SpelMessage, org.springframework.expression.spel.support.ReflectiveConstructorExecutor, org.springframework.lang.Nullable, org.springframework.util.Assert

Represents the invocation of a constructor. Either a constructor on a regular type or construction of an array. When an array is constructed, an initializer can be specified.

Examples

Authors
Andy Clement, Juergen Hoeller, Sam Brannen, Harry Yang
Since
3.0

Field Summary

Modifier and TypeField and Description
private volatile ConstructorExecutor
cachedExecutor

The cached executor that may be reused on subsequent evaluations.

private final SpelNodeImpl[]
private final boolean
private static final int
MAX_ARRAY_ELEMENTS

Maximum number of elements permitted in an array declaration, applying to one-dimensional as well as multi-dimensional arrays.

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

Constructor Summary

AccessConstructor and Description
public
ConstructorReference(int startPos, int endPos, SpelNodeImpl... arguments)

Create a constructor reference.

public
ConstructorReference(int startPos, int endPos, SpelNodeImpl[] dimensions, SpelNodeImpl... arguments)

Create a constructor reference.

Method Summary

Modifier and TypeMethod and Description
private void
checkNumElements(long numElements)

private TypedValue

Returns:

the new array
createArray
(ExpressionState
the expression state within which this expression is being evaluated
state
)

Create an array and return it.

private boolean[]
private byte[]
private char[]
createCharArray(ExpressionState state, TypeConverter typeConverter, SpelNodeImpl[] children)

private double[]
createDoubleArray(ExpressionState state, TypeConverter typeConverter, SpelNodeImpl[] children)

private float[]
createFloatArray(ExpressionState state, TypeConverter typeConverter, SpelNodeImpl[] children)

private int[]
createIntArray(ExpressionState state, TypeConverter typeConverter, SpelNodeImpl[] children)

private long[]
private TypedValue

Returns:

the new object
createNewInstance
(ExpressionState
the expression state within which this expression is being evaluated
state
)

Create a new ordinary object and return it.

private Object
createReferenceTypeArray(ExpressionState state, TypeConverter typeConverter, SpelNodeImpl[] children, Class<?> componentType)

private short[]
createShortArray(ExpressionState state, TypeConverter typeConverter, SpelNodeImpl[] children)

private ConstructorExecutor

Returns:

a reusable ConstructorExecutor that can be invoked to run the constructor or null
findExecutorForConstructor
(String
the type trying to be constructed
typeName
,
List<TypeDescriptor>
the types of the arguments supplied that the constructor must take
argumentTypes
,
ExpressionState
the current state of the expression
state
)

Go through the list of registered constructor resolvers and see if any can find a constructor that takes the specified set of arguments.

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 state)

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

Implements getValue() - delegating to the code for building an array or a simple type.
private boolean
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

Field Detail

cachedExecutorback to summary
private volatile ConstructorExecutor cachedExecutor

The cached executor that may be reused on subsequent evaluations.

Annotations
@Nullable
dimensionsback to summary
private final SpelNodeImpl[] dimensions
Annotations
@Nullable
isArrayConstructorback to summary
private final boolean isArrayConstructor
MAX_ARRAY_ELEMENTSback to summary
private static final int MAX_ARRAY_ELEMENTS

Maximum number of elements permitted in an array declaration, applying to one-dimensional as well as multi-dimensional arrays.

Since
5.3.17

Constructor Detail

ConstructorReferenceback to summary
public ConstructorReference(int startPos, int endPos, SpelNodeImpl... arguments)

Create a constructor reference. The first argument is the type, the rest are the parameters to the constructor call

ConstructorReferenceback to summary
public ConstructorReference(int startPos, int endPos, SpelNodeImpl[] dimensions, SpelNodeImpl... arguments)

Create a constructor reference. The first argument is the type, the rest are the parameters to the constructor call

Method Detail

checkNumElementsback to summary
private void checkNumElements(long numElements)
createArrayback to summary
private TypedValue createArray(ExpressionState state) throws EvaluationException

Create an array and return it.

Parameters
state:ExpressionState

the expression state within which this expression is being evaluated

Returns:TypedValue

the new array

Exceptions
EvaluationException:
if there is a problem creating the array
createBooleanArrayback to summary
private boolean[] createBooleanArray(ExpressionState state, TypeConverter typeConverter, SpelNodeImpl[] children)
createByteArrayback to summary
private byte[] createByteArray(ExpressionState state, TypeConverter converter, SpelNodeImpl[] children)
createCharArrayback to summary
private char[] createCharArray(ExpressionState state, TypeConverter typeConverter, SpelNodeImpl[] children)
createDoubleArrayback to summary
private double[] createDoubleArray(ExpressionState state, TypeConverter typeConverter, SpelNodeImpl[] children)
createFloatArrayback to summary
private float[] createFloatArray(ExpressionState state, TypeConverter typeConverter, SpelNodeImpl[] children)
createIntArrayback to summary
private int[] createIntArray(ExpressionState state, TypeConverter typeConverter, SpelNodeImpl[] children)
createLongArrayback to summary
private long[] createLongArray(ExpressionState state, TypeConverter converter, SpelNodeImpl[] children)
createNewInstanceback to summary
private TypedValue createNewInstance(ExpressionState state) throws EvaluationException

Create a new ordinary object and return it.

Parameters
state:ExpressionState

the expression state within which this expression is being evaluated

Returns:TypedValue

the new object

Exceptions
EvaluationException:
if there is a problem creating the object
createReferenceTypeArrayback to summary
private Object createReferenceTypeArray(ExpressionState state, TypeConverter typeConverter, SpelNodeImpl[] children, Class<?> componentType)
createShortArrayback to summary
private short[] createShortArray(ExpressionState state, TypeConverter typeConverter, SpelNodeImpl[] children)
findExecutorForConstructorback to summary
private ConstructorExecutor findExecutorForConstructor(String typeName, List<TypeDescriptor> argumentTypes, ExpressionState state) throws SpelEvaluationException

Go through the list of registered constructor resolvers and see if any can find a constructor that takes the specified set of arguments.

Parameters
typeName:String

the type trying to be constructed

argumentTypes:List<TypeDescriptor>

the types of the arguments supplied that the constructor must take

state:ExpressionState

the current state of the expression

Returns:ConstructorExecutor

a reusable ConstructorExecutor that can be invoked to run the constructor or null

Exceptions
SpelEvaluationException:
if there is a problem locating the constructor
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.

Implements getValue() - delegating to the code for building an array or a simple type.

Annotations
@Override
hasInitializerback to summary
private boolean hasInitializer()
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