use of cn.taketoday.expression.spel.ExpressionState in project today-framework by TAKETODAY.
the class SpelExpression method getValueTypeDescriptor.
@Override
@Nullable
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException {
Assert.notNull(context, "EvaluationContext is required");
ExpressionState expressionState = new ExpressionState(context, toTypedValue(rootObject), this.configuration);
return this.ast.getValueInternal(expressionState).getTypeDescriptor();
}
use of cn.taketoday.expression.spel.ExpressionState in project today-framework by TAKETODAY.
the class SpelExpression method setValue.
@Override
public void setValue(EvaluationContext context, @Nullable Object rootObject, @Nullable Object value) throws EvaluationException {
Assert.notNull(context, "EvaluationContext is required");
this.ast.setValue(new ExpressionState(context, toTypedValue(rootObject), this.configuration), value);
}
use of cn.taketoday.expression.spel.ExpressionState in project today-framework by TAKETODAY.
the class SpelExpression method getValueTypeDescriptor.
@Override
@Nullable
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context) throws EvaluationException {
Assert.notNull(context, "EvaluationContext is required");
ExpressionState expressionState = new ExpressionState(context, this.configuration);
return this.ast.getValueInternal(expressionState).getTypeDescriptor();
}
use of cn.taketoday.expression.spel.ExpressionState in project today-framework by TAKETODAY.
the class SpelExpression method getValue.
@Override
@Nullable
public Object getValue(EvaluationContext context) throws EvaluationException {
Assert.notNull(context, "EvaluationContext is required");
CompiledExpression compiledAst = this.compiledAst;
if (compiledAst != null) {
try {
return compiledAst.getValue(context.getRootObject().getValue(), context);
} catch (Throwable ex) {
// If running in mixed mode, revert to interpreted
if (this.configuration.getCompilerMode() == SpelCompilerMode.MIXED) {
this.compiledAst = null;
this.interpretedCount.set(0);
} else {
// Running in SpelCompilerMode.immediate mode - propagate exception to caller
throw new SpelEvaluationException(ex, SpelMessage.EXCEPTION_RUNNING_COMPILED_EXPRESSION);
}
}
}
ExpressionState expressionState = new ExpressionState(context, this.configuration);
Object result = this.ast.getValue(expressionState);
checkCompile(expressionState);
return result;
}
use of cn.taketoday.expression.spel.ExpressionState in project today-framework by TAKETODAY.
the class OpPlusTests method test_unaryPlusWithStringLiteral.
@Test
public void test_unaryPlusWithStringLiteral() {
ExpressionState expressionState = new ExpressionState(new StandardEvaluationContext());
StringLiteral str = new StringLiteral("word", -1, -1, "word");
OpPlus o = new OpPlus(-1, -1, str);
assertThatExceptionOfType(SpelEvaluationException.class).isThrownBy(() -> o.getValueInternal(expressionState));
}
Aggregations