Package org.springframework.context.expression

# Class CachedExpressionEvaluator

java.lang.Object
org.springframework.context.expression.CachedExpressionEvaluator

public abstract class CachedExpressionEvaluator extends Object
Shared utility class used to evaluate and cache SpEL expressions that are defined on an `AnnotatedElement`.

Since:
  4.2
Author:
  Stephane Nicoll
See Also:
  - `AnnotatedElementKey`

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`protected static class`
`CachedExpressionEvaluator.ExpressionKey`
An expression key.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`CachedExpressionEvaluator()`
Create a new instance with the default `SpelExpressionParser`.
`protected`
`CachedExpressionEvaluator(org.springframework.expression.spel.standard.SpelExpressionParser parser)`
Create a new instance with the specified `SpelExpressionParser`.

## Method Summary

Modifier and Type
Method
Description
`protected org.springframework.expression.Expression`
`getExpression(Map<CachedExpressionEvaluator.ExpressionKey,org.springframework.expression.Expression> cache, AnnotatedElementKey elementKey, String expression)`
Return the parsed `Expression` for the specified SpEL expression.
`protected org.springframework.core.ParameterNameDiscoverer`
`getParameterNameDiscoverer()`
Return a shared parameter name discoverer which caches data internally.
`protected org.springframework.expression.spel.standard.SpelExpressionParser`
`getParser()`
Return the `SpelExpressionParser` to use.
`protected org.springframework.expression.Expression`
`parseExpression(String expression)`
Parse the specified `expression`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### CachedExpressionEvaluator

protected CachedExpressionEvaluator()
Create a new instance with the default `SpelExpressionParser`.

### CachedExpressionEvaluator

protected CachedExpressionEvaluator(org.springframework.expression.spel.standard.SpelExpressionParser parser)
Create a new instance with the specified `SpelExpressionParser`.

## Method Details

### getParser

protected org.springframework.expression.spel.standard.SpelExpressionParser getParser()
Return the `SpelExpressionParser` to use.

### getParameterNameDiscoverer

protected org.springframework.core.ParameterNameDiscoverer getParameterNameDiscoverer()
Return a shared parameter name discoverer which caches data internally.

Since:
  4.3

### getExpression

protected org.springframework.expression.Expression getExpression(Map<CachedExpressionEvaluator.ExpressionKey,org.springframework.expression.Expression> cache, AnnotatedElementKey elementKey, String expression)
Return the parsed `Expression` for the specified SpEL expression.

Parses the expression if it hasn't already been parsed and cached.

Parameters:
  `cache` - the cache to use
  `elementKey` - the `AnnotatedElementKey` containing the element on which the expression is defined
  `expression` - the expression to parse

### parseExpression

protected org.springframework.expression.Expression parseExpression(String expression)
Parse the specified `expression`.

Parameters:
  `expression` - the expression to parse
Since:
  5.3.13