Top Description Fields Constructors Methods
org.springframework.expression.common

public Class LiteralExpression

extends Object
implements Expression
Class Inheritance
All Implemented Interfaces
org.springframework.expression.Expression
Imports
org.springframework.core.convert.TypeDescriptor, org.springframework.expression.EvaluationContext, .EvaluationException, .Expression, .TypedValue, org.springframework.lang.Nullable

A very simple, hard-coded implementation of the Expression interface that represents a string literal.

It is used with CompositeStringExpression when representing a template expression which is made up of pieces, some being real expressions to be handled by an EL implementation like SpEL, and some being just textual elements.

Authors
Andy Clement, Juergen Hoeller
Since
3.0

Field Summary

Modifier and TypeField and Description
private final String
literalValue

Fixed literal value of this expression.

Constructor Summary

AccessConstructor and Description
public
LiteralExpression(String literalValue)

Method Summary

Modifier and TypeMethod and Description
public final String
getExpressionString()

Implements org.springframework.expression.Expression.getExpressionString.

Return the original string used to create this expression (unmodified).
public String
getValue()

Implements org.springframework.expression.Expression.getValue.

Evaluate this expression in the default standard context.
public <T> T
getValue(Class<T>
the type the caller would like the result to be
expectedResultType
)

Implements org.springframework.expression.Expression.getValue.

Evaluate this expression in the default context.
public String
getValue(Object
the root object against which to evaluate the expression
rootObject
)

Implements org.springframework.expression.Expression.getValue.

Evaluate this expression against the specified root object.
public <T> T
getValue(Object
the root object against which to evaluate the expression
rootObject
,
Class<T>
the type the caller would like the result to be
desiredResultType
)

Implements org.springframework.expression.Expression.getValue.

Evaluate this expression in the default context against the specified root object.
public String
getValue(EvaluationContext
the context in which to evaluate the expression
context
)

Implements org.springframework.expression.Expression.getValue.

Evaluate this expression in the provided context and return the result of evaluation.
public <T> T
getValue(EvaluationContext
the context in which to evaluate the expression
context
,
Class<T>
the type the caller would like the result to be
expectedResultType
)

Implements org.springframework.expression.Expression.getValue.

Evaluate this expression in the provided context which can resolve references to properties, methods, types, etc. The type of the evaluation result is expected to be of a particular type, and an exception will be thrown if it is not and cannot be converted to that type.
public String
getValue(EvaluationContext
the context in which to evaluate the expression
context
,
Object
the root object against which to evaluate the expression
rootObject
)

Implements org.springframework.expression.Expression.getValue.

Evaluate this expression in the provided context and return the result of evaluation, but use the supplied root context as an override for any default root object specified in the context.
public <T> T
getValue(EvaluationContext
the context in which to evaluate the expression
context
,
Object
the root object against which to evaluate the expression
rootObject
,
Class<T>
the type the caller would like the result to be
desiredResultType
)

Implements org.springframework.expression.Expression.getValue.

Evaluate this expression in the provided context which can resolve references to properties, methods, types, etc. The type of the evaluation result is expected to be of a particular type, and an exception will be thrown if it is not and cannot be converted to that type.j

The supplied root object overrides any specified in the supplied context.

public Class<?>
getValueType(EvaluationContext
the context in which to evaluate the expression
context
)

Implements org.springframework.expression.Expression.getValueType.

Return the most general type that can be passed to the setValue(EvaluationContext, Object) method for the given context.
public Class<?>
getValueType()

Implements org.springframework.expression.Expression.getValueType.

Return the most general type that can be passed to the setValue(EvaluationContext, Object) method using the default context.
public Class<?>
getValueType(Object
the root object against which to evaluate the expression
rootObject
)

Implements org.springframework.expression.Expression.getValueType.

Return the most general type that can be passed to the setValue(Object, Object) method using the default context.
public Class<?>
getValueType(EvaluationContext
the context in which to evaluate the expression
context
,
Object
the root object against which to evaluate the expression
rootObject
)

Implements org.springframework.expression.Expression.getValueType.

Return the most general type that can be passed to the setValue(EvaluationContext, Object, Object) method for the given context.
public TypeDescriptor
getValueTypeDescriptor()

Implements org.springframework.expression.Expression.getValueTypeDescriptor.

Return a descriptor for the most general type that can be passed to one of the setValue(...) methods using the default context.
public TypeDescriptor
getValueTypeDescriptor(Object
the root object against which to evaluate the expression
rootObject
)

Implements org.springframework.expression.Expression.getValueTypeDescriptor.

Return a descriptor for the most general type that can be passed to the setValue(Object, Object) method using the default context.
public TypeDescriptor
getValueTypeDescriptor(EvaluationContext
the context in which to evaluate the expression
context
)

Implements org.springframework.expression.Expression.getValueTypeDescriptor.

Return a descriptor for the most general type that can be passed to the setValue(EvaluationContext, Object) method for the given context.
public TypeDescriptor
getValueTypeDescriptor(EvaluationContext
the context in which to evaluate the expression
context
,
Object
the root object against which to evaluate the expression
rootObject
)

Implements org.springframework.expression.Expression.getValueTypeDescriptor.

Return a descriptor for the most general type that can be passed to the setValue(EvaluationContext, Object, Object) method for the given context.
public boolean
isWritable(Object
the root object against which to evaluate the expression
rootObject
)

Implements org.springframework.expression.Expression.isWritable.

Determine if this expression can be written to, i.e. setValue() can be called.
public boolean
isWritable(EvaluationContext
the context in which the expression should be checked
context
)

Implements org.springframework.expression.Expression.isWritable.

Determine if this expression can be written to, i.e. setValue() can be called.
public boolean
isWritable(EvaluationContext
the context in which the expression should be checked
context
,
Object
the root object against which to evaluate the expression
rootObject
)

Implements org.springframework.expression.Expression.isWritable.

Determine if this expression can be written to, i.e. setValue() can be called.
public void
setValue(Object
the root object against which to evaluate the expression
rootObject
,
Object
the new value
value
)

Implements org.springframework.expression.Expression.setValue.

Set this expression in the provided context to the value provided.
public void
setValue(EvaluationContext
the context in which to set the value of the expression
context
,
Object
the new value
value
)

Implements org.springframework.expression.Expression.setValue.

Set this expression in the provided context to the value provided.
public void
setValue(EvaluationContext
the context in which to set the value of the expression
context
,
Object
the root object against which to evaluate the expression
rootObject
,
Object
the new value
value
)

Implements org.springframework.expression.Expression.setValue.

Set this expression in the provided context to the value provided.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

literalValueback to summary
private final String literalValue

Fixed literal value of this expression.

Constructor Detail

LiteralExpressionback to summary
public LiteralExpression(String literalValue)

Method Detail

getExpressionStringback to summary
public final String getExpressionString()

Implements org.springframework.expression.Expression.getExpressionString.

Doc from org.springframework.expression.Expression.getExpressionString.

Return the original string used to create this expression (unmodified).

Returns:String

the original expression string

Annotations
@Override
getValueback to summary
public String getValue()

Implements org.springframework.expression.Expression.getValue.

Doc from org.springframework.expression.Expression.getValue.

Evaluate this expression in the default standard context.

Returns:String

the evaluation result

Annotations
@Override
getValueback to summary
public <T> T getValue(Class<T> expectedResultType) throws EvaluationException

Implements org.springframework.expression.Expression.getValue.

Doc from org.springframework.expression.Expression.getValue.

Evaluate this expression in the default context. If the result of the evaluation does not match (and cannot be converted to) the expected result type then an exception will be thrown.

Parameters
expectedResultType:Class<T>

the type the caller would like the result to be

Returns:T

the evaluation result

Annotations
@Override
@Nullable
Exceptions
EvaluationException:
if there is a problem during evaluation
getValueback to summary
public String getValue(Object rootObject)

Implements org.springframework.expression.Expression.getValue.

Doc from org.springframework.expression.Expression.getValue.

Evaluate this expression against the specified root object.

Parameters
rootObject:Object

the root object against which to evaluate the expression

Returns:String

the evaluation result

Annotations
@Override
getValueback to summary
public <T> T getValue(Object rootObject, Class<T> desiredResultType) throws EvaluationException

Implements org.springframework.expression.Expression.getValue.

Doc from org.springframework.expression.Expression.getValue.

Evaluate this expression in the default context against the specified root object. If the result of the evaluation does not match (and cannot be converted to) the expected result type then an exception will be thrown.

Parameters
rootObject:Object

the root object against which to evaluate the expression

desiredResultType:Class<T>

the type the caller would like the result to be

Returns:T

the evaluation result

Annotations
@Override
@Nullable
Exceptions
EvaluationException:
if there is a problem during evaluation
getValueback to summary
public String getValue(EvaluationContext context)

Implements org.springframework.expression.Expression.getValue.

Doc from org.springframework.expression.Expression.getValue.

Evaluate this expression in the provided context and return the result of evaluation.

Parameters
context:EvaluationContext

the context in which to evaluate the expression

Returns:String

the evaluation result

Annotations
@Override
getValueback to summary
public <T> T getValue(EvaluationContext context, Class<T> expectedResultType) throws EvaluationException

Implements org.springframework.expression.Expression.getValue.

Doc from org.springframework.expression.Expression.getValue.

Evaluate this expression in the provided context which can resolve references to properties, methods, types, etc. The type of the evaluation result is expected to be of a particular type, and an exception will be thrown if it is not and cannot be converted to that type.

Parameters
context:EvaluationContext

the context in which to evaluate the expression

expectedResultType:Class<T>

the type the caller would like the result to be

Returns:T

the evaluation result

Annotations
@Override
@Nullable
Exceptions
EvaluationException:
if there is a problem during evaluation
getValueback to summary
public String getValue(EvaluationContext context, Object rootObject) throws EvaluationException

Implements org.springframework.expression.Expression.getValue.

Doc from org.springframework.expression.Expression.getValue.

Evaluate this expression in the provided context and return the result of evaluation, but use the supplied root context as an override for any default root object specified in the context.

Parameters
context:EvaluationContext

the context in which to evaluate the expression

rootObject:Object

the root object against which to evaluate the expression

Returns:String

the evaluation result

Annotations
@Override
Exceptions
EvaluationException:
if there is a problem during evaluation
getValueback to summary
public <T> T getValue(EvaluationContext context, Object rootObject, Class<T> desiredResultType) throws EvaluationException

Implements org.springframework.expression.Expression.getValue.

Doc from org.springframework.expression.Expression.getValue.

Evaluate this expression in the provided context which can resolve references to properties, methods, types, etc. The type of the evaluation result is expected to be of a particular type, and an exception will be thrown if it is not and cannot be converted to that type.j

The supplied root object overrides any specified in the supplied context.

Parameters
context:EvaluationContext

the context in which to evaluate the expression

rootObject:Object

the root object against which to evaluate the expression

desiredResultType:Class<T>

the type the caller would like the result to be

Returns:T

the evaluation result

Annotations
@Override
@Nullable
Exceptions
EvaluationException:
if there is a problem during evaluation
getValueTypeback to summary
public Class<?> getValueType(EvaluationContext context)

Implements org.springframework.expression.Expression.getValueType.

Doc from org.springframework.expression.Expression.getValueType.

Return the most general type that can be passed to the setValue(EvaluationContext, Object) method for the given context.

Parameters
context:EvaluationContext

the context in which to evaluate the expression

Returns:Class<?>

the most general type of value that can be set in this context

Annotations
@Override
getValueTypeback to summary
public Class<?> getValueType()

Implements org.springframework.expression.Expression.getValueType.

Doc from org.springframework.expression.Expression.getValueType.

Return the most general type that can be passed to the setValue(EvaluationContext, Object) method using the default context.

Returns:Class<?>

the most general type of value that can be set in this context

Annotations
@Override
getValueTypeback to summary
public Class<?> getValueType(Object rootObject) throws EvaluationException

Implements org.springframework.expression.Expression.getValueType.

Doc from org.springframework.expression.Expression.getValueType.

Return the most general type that can be passed to the setValue(Object, Object) method using the default context.

Parameters
rootObject:Object

the root object against which to evaluate the expression

Returns:Class<?>

the most general type of value that can be set in this context

Annotations
@Override
Exceptions
EvaluationException:
if there is a problem determining the type
getValueTypeback to summary
public Class<?> getValueType(EvaluationContext context, Object rootObject) throws EvaluationException

Implements org.springframework.expression.Expression.getValueType.

Doc from org.springframework.expression.Expression.getValueType.

Return the most general type that can be passed to the setValue(EvaluationContext, Object, Object) method for the given context.

The supplied root object overrides any specified in the supplied context.

Parameters
context:EvaluationContext

the context in which to evaluate the expression

rootObject:Object

the root object against which to evaluate the expression

Returns:Class<?>

the most general type of value that can be set in this context

Annotations
@Override
Exceptions
EvaluationException:
if there is a problem determining the type
getValueTypeDescriptorback to summary
public TypeDescriptor getValueTypeDescriptor()

Implements org.springframework.expression.Expression.getValueTypeDescriptor.

Doc from org.springframework.expression.Expression.getValueTypeDescriptor.

Return a descriptor for the most general type that can be passed to one of the setValue(...) methods using the default context.

Returns:TypeDescriptor

a type descriptor for values that can be set in this context

Annotations
@Override
getValueTypeDescriptorback to summary
public TypeDescriptor getValueTypeDescriptor(Object rootObject) throws EvaluationException

Implements org.springframework.expression.Expression.getValueTypeDescriptor.

Doc from org.springframework.expression.Expression.getValueTypeDescriptor.

Return a descriptor for the most general type that can be passed to the setValue(Object, Object) method using the default context.

Parameters
rootObject:Object

the root object against which to evaluate the expression

Returns:TypeDescriptor

a type descriptor for values that can be set in this context

Annotations
@Override
Exceptions
EvaluationException:
if there is a problem determining the type
getValueTypeDescriptorback to summary
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context)

Implements org.springframework.expression.Expression.getValueTypeDescriptor.

Doc from org.springframework.expression.Expression.getValueTypeDescriptor.

Return a descriptor for the most general type that can be passed to the setValue(EvaluationContext, Object) method for the given context.

Parameters
context:EvaluationContext

the context in which to evaluate the expression

Returns:TypeDescriptor

a type descriptor for values that can be set in this context

Annotations
@Override
getValueTypeDescriptorback to summary
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context, Object rootObject) throws EvaluationException

Implements org.springframework.expression.Expression.getValueTypeDescriptor.

Doc from org.springframework.expression.Expression.getValueTypeDescriptor.

Return a descriptor for the most general type that can be passed to the setValue(EvaluationContext, Object, Object) method for the given context.

The supplied root object overrides any specified in the supplied context.

Parameters
context:EvaluationContext

the context in which to evaluate the expression

rootObject:Object

the root object against which to evaluate the expression

Returns:TypeDescriptor

a type descriptor for values that can be set in this context

Annotations
@Override
Exceptions
EvaluationException:
if there is a problem determining the type
isWritableback to summary
public boolean isWritable(Object rootObject) throws EvaluationException

Implements org.springframework.expression.Expression.isWritable.

Doc from org.springframework.expression.Expression.isWritable.

Determine if this expression can be written to, i.e. setValue() can be called.

Parameters
rootObject:Object

the root object against which to evaluate the expression

Returns:boolean

true if the expression is writable; false otherwise

Annotations
@Override
Exceptions
EvaluationException:
if there is a problem determining if it is writable
isWritableback to summary
public boolean isWritable(EvaluationContext context)

Implements org.springframework.expression.Expression.isWritable.

Doc from org.springframework.expression.Expression.isWritable.

Determine if this expression can be written to, i.e. setValue() can be called.

Parameters
context:EvaluationContext

the context in which the expression should be checked

Returns:boolean

true if the expression is writable; false otherwise

Annotations
@Override
isWritableback to summary
public boolean isWritable(EvaluationContext context, Object rootObject) throws EvaluationException

Implements org.springframework.expression.Expression.isWritable.

Doc from org.springframework.expression.Expression.isWritable.

Determine if this expression can be written to, i.e. setValue() can be called.

The supplied root object overrides any specified in the supplied context.

Parameters
context:EvaluationContext

the context in which the expression should be checked

rootObject:Object

the root object against which to evaluate the expression

Returns:boolean

true if the expression is writable; false otherwise

Annotations
@Override
Exceptions
EvaluationException:
if there is a problem determining if it is writable
setValueback to summary
public void setValue(Object rootObject, Object value) throws EvaluationException

Implements org.springframework.expression.Expression.setValue.

Doc from org.springframework.expression.Expression.setValue.

Set this expression in the provided context to the value provided.

Parameters
rootObject:Object

the root object against which to evaluate the expression

value:Object

the new value

Annotations
@Override
Exceptions
EvaluationException:
if there is a problem during evaluation
setValueback to summary
public void setValue(EvaluationContext context, Object value) throws EvaluationException

Implements org.springframework.expression.Expression.setValue.

Doc from org.springframework.expression.Expression.setValue.

Set this expression in the provided context to the value provided.

Parameters
context:EvaluationContext

the context in which to set the value of the expression

value:Object

the new value

Annotations
@Override
Exceptions
EvaluationException:
if there is a problem during evaluation
setValueback to summary
public void setValue(EvaluationContext context, Object rootObject, Object value) throws EvaluationException

Implements org.springframework.expression.Expression.setValue.

Doc from org.springframework.expression.Expression.setValue.

Set this expression in the provided context to the value provided.

The supplied root object overrides any specified in the supplied context.

Parameters
context:EvaluationContext

the context in which to set the value of the expression

rootObject:Object

the root object against which to evaluate the expression

value:Object

the new value

Annotations
@Override
Exceptions
EvaluationException:
if there is a problem during evaluation