Package org.springframework.expression.common

# Class CompositeStringExpression

java.lang.Object
org.springframework.expression.common.CompositeStringExpression

All Implemented Interfaces:
  `Expression`

public class CompositeStringExpression extends Object implements Expression
Represents a template expression broken into pieces.

Each piece will be an `Expression`, but pure text parts of the template will be represented as `LiteralExpression` objects. An example of a template expression might be:

     "Hello ${getName()}"

which will be represented as a `CompositeStringExpression` of two parts: the first part being a `LiteralExpression` representing 'Hello ' and the second part being a real expression that will call `getName()` when invoked.

Since:
  3.0
Author:
  Andy Clement, Juergen Hoeller

## Constructor Summary

Constructors
Constructor
Description
`CompositeStringExpression(String expressionString, Expression[] expressions)`

## Method Summary

Modifier and Type
Method
Description
`final Expression[]`
`getExpressions()`
`final String`
`getExpressionString()`
Return the original string used to create this expression (unmodified).
`String`
`getValue()`
Evaluate this expression in the default context and return the result of evaluation.
`<T> T`
`getValue(Class<T> expectedResultType)`
Evaluate this expression in the default context and return the result of evaluation.
`String`
`getValue(Object rootObject)`
Evaluate this expression in the default context against the specified root object and return the result of evaluation.
`<T> T`
`getValue(Object rootObject, Class<T> desiredResultType)`
Evaluate this expression in the default context against the specified root object and return the result of evaluation.
`String`
`getValue(EvaluationContext context)`
Evaluate this expression in the provided context and return the result of evaluation.
`<T> T`
`getValue(EvaluationContext context, Class<T> expectedResultType)`
Evaluate this expression in the provided context and return the result of evaluation.
`String`
`getValue(EvaluationContext context, Object rootObject)`
Evaluate this expression in the provided context against the specified root object and return the result of evaluation.
`<T> T`
`getValue(EvaluationContext context, Object rootObject, Class<T> desiredResultType)`
Evaluate this expression in the provided context against the specified root object and return the result of evaluation.
`Class<?>`
`getValueType()`
Return the most general type that can be passed to the `Expression.setValue(EvaluationContext, Object)` method using the default context.
`Class<?>`
`getValueType(Object rootObject)`
Return the most general type that can be passed to the `Expression.setValue(Object, Object)` method using the default context.
`Class<?>`
`getValueType(EvaluationContext context)`
Return the most general type that can be passed to the `Expression.setValue(EvaluationContext, Object)` method for the given context.
`Class<?>`
`getValueType(EvaluationContext context, Object rootObject)`
Return the most general type that can be passed to the `Expression.setValue(EvaluationContext, Object, Object)` method for the given context.
`org.springframework.core.convert.TypeDescriptor`
`getValueTypeDescriptor()`
Return a descriptor for the most general type that can be passed to one of the `setValue(...)` methods using the default context.
`org.springframework.core.convert.TypeDescriptor`
`getValueTypeDescriptor(Object rootObject)`
Return a descriptor for the most general type that can be passed to the `Expression.setValue(Object, Object)` method using the default context.
`org.springframework.core.convert.TypeDescriptor`
`getValueTypeDescriptor(EvaluationContext context)`
Return a descriptor for the most general type that can be passed to the `Expression.setValue(EvaluationContext, Object)` method for the given context.
`org.springframework.core.convert.TypeDescriptor`
`getValueTypeDescriptor(EvaluationContext context, Object rootObject)`
Return a descriptor for the most general type that can be passed to the `Expression.setValue(EvaluationContext, Object, Object)` method for the given context.
`boolean`
`isWritable(Object rootObject)`
Determine if this expression can be written to, i.e.
`boolean`
`isWritable(EvaluationContext context)`
Determine if this expression can be written to, i.e.
`boolean`
`isWritable(EvaluationContext context, Object rootObject)`
Determine if this expression can be written to, i.e.
`void`
`setValue(Object rootObject, Object value)`
Set this expression in the default context to the value provided.
`void`
`setValue(EvaluationContext context, Object value)`
Set this expression in the provided context to the value provided.
`void`
`setValue(EvaluationContext context, Object rootObject, Object value)`
Set this expression in the provided context to the value provided.

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

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

## Constructor Details

### CompositeStringExpression

public CompositeStringExpression(String expressionString, Expression[] expressions)

## Method Details

### getExpressionString

public final String getExpressionString()
Description copied from interface: `Expression`
Return the original string used to create this expression (unmodified).

Specified by:
  `getExpressionString` in interface `Expression`
Returns:
  the original expression string

### getExpressions

public final Expression[] getExpressions()

### getValue

public String getValue() throws EvaluationException
Description copied from interface: `Expression`
Evaluate this expression in the default context and return the result of evaluation.

Specified by:
  `getValue` in interface `Expression`
Returns:
  the evaluation result
Throws:
  `EvaluationException` - if there is a problem during evaluation

### getValue

@Nullable public <T> T getValue(@Nullable Class<T> expectedResultType) throws EvaluationException
Description copied from interface: `Expression`
Evaluate this expression in the default context and return the result of evaluation.

If the result of the evaluation does not match (and cannot be converted to) the expected result type then an exception will be thrown.

Specified by:
  `getValue` in interface `Expression`
Parameters:
  `expectedResultType` - the type the caller would like the result to be
Returns:
  the evaluation result
Throws:
  `EvaluationException` - if there is a problem during evaluation

### getValue

public String getValue(@Nullable Object rootObject) throws EvaluationException
Description copied from interface: `Expression`
Evaluate this expression in the default context against the specified root object and return the result of evaluation.

Specified by:
  `getValue` in interface `Expression`
Parameters:
  `rootObject` - the root object against which to evaluate the expression
Returns:
  the evaluation result
Throws:
  `EvaluationException` - if there is a problem during evaluation

### getValue

@Nullable public <T> T getValue(@Nullable Object rootObject, @Nullable Class<T> desiredResultType) throws EvaluationException
Description copied from interface: `Expression`
Evaluate this expression in the default context against the specified root object and return the result of evaluation.

If the result of the evaluation does not match (and cannot be converted to) the expected result type then an exception will be thrown.

Specified by:
  `getValue` in interface `Expression`
Parameters:
  `rootObject` - the root object against which to evaluate the expression
  `desiredResultType` - the type the caller would like the result to be
Returns:
  the evaluation result
Throws:
  `EvaluationException` - if there is a problem during evaluation

### getValue

public String getValue(EvaluationContext context) throws EvaluationException
Description copied from interface: `Expression`
Evaluate this expression in the provided context and return the result of evaluation.

Specified by:
  `getValue` in interface `Expression`
Parameters:
  `context` - the context in which to evaluate the expression
Returns:
  the evaluation result
Throws:
  `EvaluationException` - if there is a problem during evaluation

### getValue

@Nullable public <T> T getValue(EvaluationContext context, @Nullable Class<T> expectedResultType) throws EvaluationException
Description copied from interface: `Expression`
Evaluate this expression in the provided context and return the result of evaluation.

If the result of the evaluation does not match (and cannot be converted to) the expected result type then an exception will be thrown.

Specified by:
  `getValue` in interface `Expression`
Parameters:
  `context` - the context in which to evaluate the expression
  `expectedResultType` - the type the caller would like the result to be
Returns:
  the evaluation result
Throws:
  `EvaluationException` - if there is a problem during evaluation

### getValue

public String getValue(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException
Description copied from interface: `Expression`
Evaluate this expression in the provided context against the specified root object and return the result of evaluation.

The supplied root object will be used as an override for any default root object configured in the context.

Specified by:
  `getValue` in interface `Expression`
Parameters:
  `context` - the context in which to evaluate the expression
  `rootObject` - the root object against which to evaluate the expression
Returns:
  the evaluation result
Throws:
  `EvaluationException` - if there is a problem during evaluation

### getValue

@Nullable public <T> T getValue(EvaluationContext context, @Nullable Object rootObject, @Nullable Class<T> desiredResultType) throws EvaluationException
Description copied from interface: `Expression`
Evaluate this expression in the provided context against the specified root object and return the result of evaluation.

The supplied root object will be used as an override for any default root object configured in the 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.

Specified by:
  `getValue` in interface `Expression`
Parameters:
  `context` - the context in which to evaluate the expression
  `rootObject` - the root object against which to evaluate the expression
  `desiredResultType` - the type the caller would like the result to be
Returns:
  the evaluation result
Throws:
  `EvaluationException` - if there is a problem during evaluation

### getValueType

public Class<?> getValueType()
Description copied from interface: `Expression`
Return the most general type that can be passed to the `Expression.setValue(EvaluationContext, Object)` method using the default context.

Specified by:
  `getValueType` in interface `Expression`
Returns:
  the most general type of value that can be set in this context

### getValueType

public Class<?> getValueType(EvaluationContext context)
Description copied from interface: `Expression`
Return the most general type that can be passed to the `Expression.setValue(EvaluationContext, Object)` method for the given context.

Specified by:
  `getValueType` in interface `Expression`
Parameters:
  `context` - the context in which to evaluate the expression
Returns:
  the most general type of value that can be set in this context

### getValueType

public Class<?> getValueType(@Nullable Object rootObject) throws EvaluationException
Description copied from interface: `Expression`
Return the most general type that can be passed to the `Expression.setValue(Object, Object)` method using the default context.

Specified by:
  `getValueType` in interface `Expression`
Parameters:
  `rootObject` - the root object against which to evaluate the expression
Returns:
  the most general type of value that can be set in this context
Throws:
  `EvaluationException` - if there is a problem determining the type

### getValueType

public Class<?> getValueType(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException
Description copied from interface: `Expression`
Return the most general type that can be passed to the `Expression.setValue(EvaluationContext, Object, Object)` method for the given context.

The supplied root object will be used as an override for any default root object configured in the context.

Specified by:
  `getValueType` in interface `Expression`
Parameters:
  `context` - the context in which to evaluate the expression
  `rootObject` - the root object against which to evaluate the expression
Returns:
  the most general type of value that can be set in this context
Throws:
  `EvaluationException` - if there is a problem determining the type

### getValueTypeDescriptor

public org.springframework.core.convert.TypeDescriptor getValueTypeDescriptor()
Description copied from interface: `Expression`
Return a descriptor for the most general type that can be passed to one of the `setValue(...)` methods using the default context.

Specified by:
  `getValueTypeDescriptor` in interface `Expression`
Returns:
  a type descriptor for values that can be set in this context

### getValueTypeDescriptor

public org.springframework.core.convert.TypeDescriptor getValueTypeDescriptor(@Nullable Object rootObject) throws EvaluationException
Description copied from interface: `Expression`
Return a descriptor for the most general type that can be passed to the `Expression.setValue(Object, Object)` method using the default context.

Specified by:
  `getValueTypeDescriptor` in interface `Expression`
Parameters:
  `rootObject` - the root object against which to evaluate the expression
Returns:
  a type descriptor for values that can be set in this context
Throws:
  `EvaluationException` - if there is a problem determining the type

### getValueTypeDescriptor

public org.springframework.core.convert.TypeDescriptor getValueTypeDescriptor(EvaluationContext context)
Description copied from interface: `Expression`
Return a descriptor for the most general type that can be passed to the `Expression.setValue(EvaluationContext, Object)` method for the given context.

Specified by:
  `getValueTypeDescriptor` in interface `Expression`
Parameters:
  `context` - the context in which to evaluate the expression
Returns:
  a type descriptor for values that can be set in this context

### getValueTypeDescriptor

public org.springframework.core.convert.TypeDescriptor getValueTypeDescriptor(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException
Description copied from interface: `Expression`
Return a descriptor for the most general type that can be passed to the `Expression.setValue(EvaluationContext, Object, Object)` method for the given context.

The supplied root object will be used as an override for any default root object configured in the context.

Specified by:
  `getValueTypeDescriptor` in interface `Expression`
Parameters:
  `context` - the context in which to evaluate the expression
  `rootObject` - the root object against which to evaluate the expression
Returns:
  a type descriptor for values that can be set in this context
Throws:
  `EvaluationException` - if there is a problem determining the type

### isWritable

public boolean isWritable(@Nullable Object rootObject) throws EvaluationException
Description copied from interface: `Expression`
Determine if this expression can be written to, i.e. setValue() can be called.

Specified by:
  `isWritable` in interface `Expression`
Parameters:
  `rootObject` - the root object against which to evaluate the expression
Returns:
  `true` if the expression is writable; `false` otherwise
Throws:
  `EvaluationException` - if there is a problem determining if it is writable

### isWritable

public boolean isWritable(EvaluationContext context)
Description copied from interface: `Expression`
Determine if this expression can be written to, i.e. setValue() can be called.

Specified by:
  `isWritable` in interface `Expression`
Parameters:
  `context` - the context in which the expression should be checked
Returns:
  `true` if the expression is writable; `false` otherwise

### isWritable

public boolean isWritable(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException
Description copied from interface: `Expression`
Determine if this expression can be written to, i.e. setValue() can be called.

The supplied root object will be used as an override for any default root object configured in the context.

Specified by:
  `isWritable` in interface `Expression`
Parameters:
  `context` - the context in which the expression should be checked
  `rootObject` - the root object against which to evaluate the expression
Returns:
  `true` if the expression is writable; `false` otherwise
Throws:
  `EvaluationException` - if there is a problem determining if it is writable

### setValue

public void setValue(@Nullable Object rootObject, @Nullable Object value) throws EvaluationException
Description copied from interface: `Expression`
Set this expression in the default context to the value provided.

Specified by:
  `setValue` in interface `Expression`
Parameters:
  `rootObject` - the root object against which to evaluate the expression
  `value` - the new value
Throws:
  `EvaluationException` - if there is a problem during evaluation

### setValue

public void setValue(EvaluationContext context, @Nullable Object value) throws EvaluationException
Description copied from interface: `Expression`
Set this expression in the provided context to the value provided.

Specified by:
  `setValue` in interface `Expression`
Parameters:
  `context` - the context in which to set the value of the expression
  `value` - the new value
Throws:
  `EvaluationException` - if there is a problem during evaluation

### setValue

public void setValue(EvaluationContext context, @Nullable Object rootObject, @Nullable Object value) throws EvaluationException
Description copied from interface: `Expression`
Set this expression in the provided context to the value provided.

The supplied root object will be used as an override for any default root object configured in the context.

Specified by:
  `setValue` in interface `Expression`
Parameters:
  `context` - the context in which to set the value of the expression
  `rootObject` - the root object against which to evaluate the expression
  `value` - the new value
Throws:
  `EvaluationException` - if there is a problem during evaluation