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

public Class Indexer

extends SpelNodeImpl
Class Inheritance
Imports
java.lang.reflect.Constructor, .Field, .Member, .Method, .Modifier, java.util.Collection, .List, .Map, java.util.function.Supplier, org.springframework.asm.MethodVisitor, org.springframework.core.convert.TypeDescriptor, org.springframework.expression.AccessException, .EvaluationContext, .EvaluationException, .PropertyAccessor, .TypeConverter, .TypedValue, org.springframework.expression.spel.CodeFlow, .ExpressionState, .SpelEvaluationException, .SpelMessage, org.springframework.expression.spel.support.ReflectivePropertyAccessor, org.springframework.lang.Nullable, org.springframework.util.Assert, .ReflectionUtils

An Indexer can index into some proceeding structure to access a particular piece of it.

Supported structures are: strings / collections (lists/sets) / arrays.

Authors
Andy Clement, Phillip Webb, Stephane Nicoll, Sam Brannen
Since
3.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private class
private static enum
private class
private class
private class

Field Summary

Modifier and TypeField and Description
private PropertyAccessor
private String
private Class<?>
private PropertyAccessor
private String
private Class<?>
private Indexer.IndexedType
Inherited from org.springframework.expression.spel.ast.SpelNodeImpl:
childrenexitTypeDescriptor

Constructor Summary

AccessConstructor and Description
public
Indexer(int startPos, int endPos, SpelNodeImpl expr)

Method Summary

Modifier and TypeMethod and Description
private Object
accessArrayElement(Object ctx, int idx)

private void
checkAccess(int arrayLength, int index)

private <T> T
convertValue(TypeConverter converter, Object value, Class<T> targetType)

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
protected ValueRef
public boolean
isCompilable()

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

Check whether a node can be compiled to bytecode.

public boolean
isWritable(ExpressionState
the current expression state (includes the context)
expressionState
)

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

Implements org.springframework.expression.spel.SpelNode.isWritable.

Determine if this expression node will support a setValue() call.

private void
setArrayElement(TypeConverter converter, Object ctx, int idx, Object newValue, Class<?> arrayComponentType)

public TypedValue
setValueInternal(ExpressionState
the current expression state (includes the context)
state
,
Supplier<TypedValue>
a supplier of the new value
valueSupplier
)

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

Evaluate the expression to a node and then set the new value created by the specified Supplier on that node.

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:
generateCodeForArgumentgenerateCodeForArgumentsgetChildgetChildCountgetEndPositiongetExitDescriptorgetObjectClassgetStartPositiongetTypedValuegetValuegetValuenextChildIssetValue

Field Detail

cachedReadAccessorback to summary
private PropertyAccessor cachedReadAccessor
Annotations
@Nullable
cachedReadNameback to summary
private String cachedReadName
Annotations
@Nullable
cachedReadTargetTypeback to summary
private Class<?> cachedReadTargetType
Annotations
@Nullable
cachedWriteAccessorback to summary
private PropertyAccessor cachedWriteAccessor
Annotations
@Nullable
cachedWriteNameback to summary
private String cachedWriteName
Annotations
@Nullable
cachedWriteTargetTypeback to summary
private Class<?> cachedWriteTargetType
Annotations
@Nullable
indexedTypeback to summary
private Indexer.IndexedType indexedType
Annotations
@Nullable

Constructor Detail

Indexerback to summary
public Indexer(int startPos, int endPos, SpelNodeImpl expr)

Method Detail

accessArrayElementback to summary
private Object accessArrayElement(Object ctx, int idx) throws SpelEvaluationException
checkAccessback to summary
private void checkAccess(int arrayLength, int index) throws SpelEvaluationException
convertValueback to summary
private <T> T convertValue(TypeConverter converter, Object value, Class<T> targetType)
Annotations
@SuppressWarnings:unchecked
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.

Annotations
@Override
getValueRefback to summary
protected ValueRef getValueRef(ExpressionState state) throws EvaluationException

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

Annotations
@Override
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
isWritableback to summary
public boolean isWritable(ExpressionState expressionState) throws SpelEvaluationException

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

Implements org.springframework.expression.spel.SpelNode.isWritable.

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

Determine if this expression node will support a setValue() call.

Parameters
expressionState:ExpressionState

the current expression state (includes the context)

Returns:boolean

true if the expression node will allow setValue()

Annotations
@Override
setArrayElementback to summary
private void setArrayElement(TypeConverter converter, Object ctx, int idx, Object newValue, Class<?> arrayComponentType) throws EvaluationException
setValueInternalback to summary
public TypedValue setValueInternal(ExpressionState state, Supplier<TypedValue> valueSupplier) throws EvaluationException

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

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

Evaluate the expression to a node and then set the new value created by the specified Supplier on that node.

For example, if the expression evaluates to a property reference, then the property will be set to the new value.

Favor this method over setValue(ExpressionState, Object) when the value should be lazily computed.

By default, this method throws a SpelEvaluationException, effectively disabling this feature. Subclasses may override this method to provide an actual implementation.

Parameters
state:ExpressionState

the current expression state (includes the context)

valueSupplier:Supplier<TypedValue>

a supplier of the new value

Annotations
@Override
Exceptions
EvaluationException:
if any problem occurs evaluating the expression or setting the new value
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
org.springframework.expression.spel.ast back to summary

private Class Indexer.ArrayIndexingValueRef

extends Object
implements ValueRef
Class Inheritance
  • java.lang.Object
  • org.springframework.expression.spel.ast.Indexer.ArrayIndexingValueRef
All Implemented Interfaces
org.springframework.expression.spel.ast.ValueRef

Field Summary

Modifier and TypeField and Description
private final Object
private final int
private final TypeConverter
private final TypeDescriptor

Constructor Summary

AccessConstructor and Description
pack-priv
ArrayIndexingValueRef(TypeConverter typeConverter, Object array, int index, TypeDescriptor typeDescriptor)

Method Summary

Modifier and TypeMethod and Description
public TypedValue
getValue()

Implements org.springframework.expression.spel.ast.ValueRef.getValue.

Returns the value this ValueRef points to, it should not require expression component re-evaluation.

public boolean
isWritable()

Implements org.springframework.expression.spel.ast.ValueRef.isWritable.

Indicates whether calling setValue(Object) is supported.

public void
setValue(Object
the new value
newValue
)

Implements org.springframework.expression.spel.ast.ValueRef.setValue.

Sets the value this ValueRef points to, it should not require expression component re-evaluation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

arrayback to summary
private final Object array
indexback to summary
private final int index
typeConverterback to summary
private final TypeConverter typeConverter
typeDescriptorback to summary
private final TypeDescriptor typeDescriptor

Constructor Detail

ArrayIndexingValueRefback to summary
pack-priv ArrayIndexingValueRef(TypeConverter typeConverter, Object array, int index, TypeDescriptor typeDescriptor)

Method Detail

getValueback to summary
public TypedValue getValue()

Implements org.springframework.expression.spel.ast.ValueRef.getValue.

Doc from org.springframework.expression.spel.ast.ValueRef.getValue.

Returns the value this ValueRef points to, it should not require expression component re-evaluation.

Returns:TypedValue

the value

Annotations
@Override
isWritableback to summary
public boolean isWritable()

Implements org.springframework.expression.spel.ast.ValueRef.isWritable.

Doc from org.springframework.expression.spel.ast.ValueRef.isWritable.

Indicates whether calling setValue(Object) is supported.

Returns:boolean

true if setValue() is supported for this value reference.

Annotations
@Override
setValueback to summary
public void setValue(Object newValue)

Implements org.springframework.expression.spel.ast.ValueRef.setValue.

Doc from org.springframework.expression.spel.ast.ValueRef.setValue.

Sets the value this ValueRef points to, it should not require expression component re-evaluation.

Parameters
newValue:Object

the new value

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

private Class Indexer.CollectionIndexingValueRef

extends Object
implements ValueRef
Class Inheritance
  • java.lang.Object
  • org.springframework.expression.spel.ast.Indexer.CollectionIndexingValueRef
All Implemented Interfaces
org.springframework.expression.spel.ast.ValueRef
Annotations
@SuppressWarnings:rawtypes, unchecked

Field Summary

Modifier and TypeField and Description
private final Collection<E>
private final TypeDescriptor
private final boolean
private final int
private final int
private final TypeConverter

Constructor Summary

AccessConstructor and Description
public
CollectionIndexingValueRef(Collection<E> collection, int index, TypeDescriptor collectionEntryDescriptor, TypeConverter typeConverter, boolean growCollection, int maximumSize)

Method Summary

Modifier and TypeMethod and Description
private Constructor<?>
public TypedValue
getValue()

Implements org.springframework.expression.spel.ast.ValueRef.getValue.

Returns the value this ValueRef points to, it should not require expression component re-evaluation.

private void
public boolean
isWritable()

Implements org.springframework.expression.spel.ast.ValueRef.isWritable.

Indicates whether calling setValue(Object) is supported.

public void
setValue(Object
the new value
newValue
)

Implements org.springframework.expression.spel.ast.ValueRef.setValue.

Sets the value this ValueRef points to, it should not require expression component re-evaluation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

collectionback to summary
private final Collection<E> collection
collectionEntryDescriptorback to summary
private final TypeDescriptor collectionEntryDescriptor
growCollectionback to summary
private final boolean growCollection
indexback to summary
private final int index
maximumSizeback to summary
private final int maximumSize
typeConverterback to summary
private final TypeConverter typeConverter

Constructor Detail

CollectionIndexingValueRefback to summary
public CollectionIndexingValueRef(Collection<E> collection, int index, TypeDescriptor collectionEntryDescriptor, TypeConverter typeConverter, boolean growCollection, int maximumSize)

Method Detail

getDefaultConstructorback to summary
private Constructor<?> getDefaultConstructor(Class<?> type)
Annotations
@Nullable
getValueback to summary
public TypedValue getValue()

Implements org.springframework.expression.spel.ast.ValueRef.getValue.

Doc from org.springframework.expression.spel.ast.ValueRef.getValue.

Returns the value this ValueRef points to, it should not require expression component re-evaluation.

Returns:TypedValue

the value

Annotations
@Override
growCollectionIfNecessaryback to summary
private void growCollectionIfNecessary()
isWritableback to summary
public boolean isWritable()

Implements org.springframework.expression.spel.ast.ValueRef.isWritable.

Doc from org.springframework.expression.spel.ast.ValueRef.isWritable.

Indicates whether calling setValue(Object) is supported.

Returns:boolean

true if setValue() is supported for this value reference.

Annotations
@Override
setValueback to summary
public void setValue(Object newValue)

Implements org.springframework.expression.spel.ast.ValueRef.setValue.

Doc from org.springframework.expression.spel.ast.ValueRef.setValue.

Sets the value this ValueRef points to, it should not require expression component re-evaluation.

Parameters
newValue:Object

the new value

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

private final Enum Indexer.IndexedType

extends Enum<Indexer.IndexedType>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final Indexer.IndexedType
public static final Indexer.IndexedType
public static final Indexer.IndexedType
public static final Indexer.IndexedType
public static final Indexer.IndexedType

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Indexer.IndexedType
public static Indexer.IndexedType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ARRAYback to summary
public static final Indexer.IndexedType ARRAY
LISTback to summary
public static final Indexer.IndexedType LIST
MAPback to summary
public static final Indexer.IndexedType MAP
OBJECTback to summary
public static final Indexer.IndexedType OBJECT
STRINGback to summary
public static final Indexer.IndexedType STRING

Constructor Detail

IndexedTypeback to summary
private IndexedType()

Method Detail

valueOfback to summary
public static Indexer.IndexedType valueOf(String name)
valuesback to summary
public static Indexer.IndexedType[] values()
org.springframework.expression.spel.ast back to summary

private Class Indexer.MapIndexingValueRef

extends Object
implements ValueRef
Class Inheritance
  • java.lang.Object
  • org.springframework.expression.spel.ast.Indexer.MapIndexingValueRef
All Implemented Interfaces
org.springframework.expression.spel.ast.ValueRef
Annotations
@SuppressWarnings:rawtypes, unchecked

Field Summary

Modifier and TypeField and Description
private final Object
private final Map<K, V>
private final TypeDescriptor
private final TypeConverter

Constructor Summary

AccessConstructor and Description
public
MapIndexingValueRef(TypeConverter typeConverter, Map<K, V> map, Object key, TypeDescriptor mapEntryDescriptor)

Method Summary

Modifier and TypeMethod and Description
public TypedValue
getValue()

Implements org.springframework.expression.spel.ast.ValueRef.getValue.

Returns the value this ValueRef points to, it should not require expression component re-evaluation.

public boolean
isWritable()

Implements org.springframework.expression.spel.ast.ValueRef.isWritable.

Indicates whether calling setValue(Object) is supported.

public void
setValue(Object
the new value
newValue
)

Implements org.springframework.expression.spel.ast.ValueRef.setValue.

Sets the value this ValueRef points to, it should not require expression component re-evaluation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

keyback to summary
private final Object key
Annotations
@Nullable
mapback to summary
private final Map<K, V> map
mapEntryDescriptorback to summary
private final TypeDescriptor mapEntryDescriptor
typeConverterback to summary
private final TypeConverter typeConverter

Constructor Detail

MapIndexingValueRefback to summary
public MapIndexingValueRef(TypeConverter typeConverter, Map<K, V> map, Object key, TypeDescriptor mapEntryDescriptor)

Method Detail

getValueback to summary
public TypedValue getValue()

Implements org.springframework.expression.spel.ast.ValueRef.getValue.

Doc from org.springframework.expression.spel.ast.ValueRef.getValue.

Returns the value this ValueRef points to, it should not require expression component re-evaluation.

Returns:TypedValue

the value

Annotations
@Override
isWritableback to summary
public boolean isWritable()

Implements org.springframework.expression.spel.ast.ValueRef.isWritable.

Doc from org.springframework.expression.spel.ast.ValueRef.isWritable.

Indicates whether calling setValue(Object) is supported.

Returns:boolean

true if setValue() is supported for this value reference.

Annotations
@Override
setValueback to summary
public void setValue(Object newValue)

Implements org.springframework.expression.spel.ast.ValueRef.setValue.

Doc from org.springframework.expression.spel.ast.ValueRef.setValue.

Sets the value this ValueRef points to, it should not require expression component re-evaluation.

Parameters
newValue:Object

the new value

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

private Class Indexer.PropertyIndexingValueRef

extends Object
implements ValueRef
Class Inheritance
  • java.lang.Object
  • org.springframework.expression.spel.ast.Indexer.PropertyIndexingValueRef
All Implemented Interfaces
org.springframework.expression.spel.ast.ValueRef

Field Summary

Modifier and TypeField and Description
private final EvaluationContext
private final String
private final Object
private final TypeDescriptor

Constructor Summary

AccessConstructor and Description
public
PropertyIndexingValueRef(Object targetObject, String value, EvaluationContext evaluationContext, TypeDescriptor targetObjectTypeDescriptor)

Method Summary

Modifier and TypeMethod and Description
public TypedValue
getValue()

Implements org.springframework.expression.spel.ast.ValueRef.getValue.

Returns the value this ValueRef points to, it should not require expression component re-evaluation.

public boolean
isWritable()

Implements org.springframework.expression.spel.ast.ValueRef.isWritable.

Indicates whether calling setValue(Object) is supported.

public void
setValue(Object
the new value
newValue
)

Implements org.springframework.expression.spel.ast.ValueRef.setValue.

Sets the value this ValueRef points to, it should not require expression component re-evaluation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

evaluationContextback to summary
private final EvaluationContext evaluationContext
nameback to summary
private final String name
targetObjectback to summary
private final Object targetObject
targetObjectTypeDescriptorback to summary
private final TypeDescriptor targetObjectTypeDescriptor

Constructor Detail

PropertyIndexingValueRefback to summary
public PropertyIndexingValueRef(Object targetObject, String value, EvaluationContext evaluationContext, TypeDescriptor targetObjectTypeDescriptor)

Method Detail

getValueback to summary
public TypedValue getValue()

Implements org.springframework.expression.spel.ast.ValueRef.getValue.

Doc from org.springframework.expression.spel.ast.ValueRef.getValue.

Returns the value this ValueRef points to, it should not require expression component re-evaluation.

Returns:TypedValue

the value

Annotations
@Override
isWritableback to summary
public boolean isWritable()

Implements org.springframework.expression.spel.ast.ValueRef.isWritable.

Doc from org.springframework.expression.spel.ast.ValueRef.isWritable.

Indicates whether calling setValue(Object) is supported.

Returns:boolean

true if setValue() is supported for this value reference.

Annotations
@Override
setValueback to summary
public void setValue(Object newValue)

Implements org.springframework.expression.spel.ast.ValueRef.setValue.

Doc from org.springframework.expression.spel.ast.ValueRef.setValue.

Sets the value this ValueRef points to, it should not require expression component re-evaluation.

Parameters
newValue:Object

the new value

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

private Class Indexer.StringIndexingValueRef

extends Object
implements ValueRef
Class Inheritance
  • java.lang.Object
  • org.springframework.expression.spel.ast.Indexer.StringIndexingValueRef
All Implemented Interfaces
org.springframework.expression.spel.ast.ValueRef

Field Summary

Modifier and TypeField and Description
private final int
private final String
private final TypeDescriptor

Constructor Summary

AccessConstructor and Description
public
StringIndexingValueRef(String target, int index, TypeDescriptor typeDescriptor)

Method Summary

Modifier and TypeMethod and Description
public TypedValue
getValue()

Implements org.springframework.expression.spel.ast.ValueRef.getValue.

Returns the value this ValueRef points to, it should not require expression component re-evaluation.

public boolean
isWritable()

Implements org.springframework.expression.spel.ast.ValueRef.isWritable.

Indicates whether calling setValue(Object) is supported.

public void
setValue(Object
the new value
newValue
)

Implements org.springframework.expression.spel.ast.ValueRef.setValue.

Sets the value this ValueRef points to, it should not require expression component re-evaluation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

indexback to summary
private final int index
targetback to summary
private final String target
typeDescriptorback to summary
private final TypeDescriptor typeDescriptor

Constructor Detail

StringIndexingValueRefback to summary
public StringIndexingValueRef(String target, int index, TypeDescriptor typeDescriptor)

Method Detail

getValueback to summary
public TypedValue getValue()

Implements org.springframework.expression.spel.ast.ValueRef.getValue.

Doc from org.springframework.expression.spel.ast.ValueRef.getValue.

Returns the value this ValueRef points to, it should not require expression component re-evaluation.

Returns:TypedValue

the value

Annotations
@Override
isWritableback to summary
public boolean isWritable()

Implements org.springframework.expression.spel.ast.ValueRef.isWritable.

Doc from org.springframework.expression.spel.ast.ValueRef.isWritable.

Indicates whether calling setValue(Object) is supported.

Returns:boolean

true if setValue() is supported for this value reference.

Annotations
@Override
setValueback to summary
public void setValue(Object newValue)

Implements org.springframework.expression.spel.ast.ValueRef.setValue.

Doc from org.springframework.expression.spel.ast.ValueRef.setValue.

Sets the value this ValueRef points to, it should not require expression component re-evaluation.

Parameters
newValue:Object

the new value

Annotations
@Override