public ExpressionState(EvaluationContext context, SpelParserConfiguration configuration) { this(context, context.getRootObject(), configuration); }
public ExpressionState(EvaluationContext context, SpelParserConfiguration configuration) { this(context, context.getRootObject(), configuration); }
public ExpressionState(EvaluationContext context) { this(context, context.getRootObject(), new SpelParserConfiguration(false, false)); }
public ExpressionState(EvaluationContext context) { this(context, context.getRootObject(), new SpelParserConfiguration(false, false)); }
public void setReturnObject(Object returnObject, EvaluationContext ctx) { ((MethodSecurityExpressionOperations) ctx.getRootObject().getValue()) .setReturnObject(returnObject); }
public void setReturnObject(Object returnObject, EvaluationContext ctx) { ((MethodSecurityExpressionOperations) ctx.getRootObject().getValue()) .setReturnObject(returnObject); }
@Override @Nullable public Object getValue(EvaluationContext context) throws EvaluationException { Assert.notNull(context, "EvaluationContext is required"); if (this.compiledAst != null) { try { return this.compiledAst.getValue(context.getRootObject().getValue(), context); } catch (Throwable ex) { // If running in mixed mode, revert to interpreted if (this.configuration.getCompilerMode() == SpelCompilerMode.MIXED) { this.interpretedCount = 0; this.compiledAst = null; } 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; }
Object result = this.compiledAst.getValue(context.getRootObject().getValue(), context); if (expectedResultType != null) { return ExpressionUtils.convertTypedValue(context, new TypedValue(result), expectedResultType);
EvaluationContext ctx) { MethodSecurityExpressionOperations rootObject = (MethodSecurityExpressionOperations) ctx .getRootObject().getValue(); final boolean debug = logger.isDebugEnabled(); List retainList;
EvaluationContext ctx) { MethodSecurityExpressionOperations rootObject = (MethodSecurityExpressionOperations) ctx .getRootObject().getValue(); final boolean debug = logger.isDebugEnabled(); List retainList;
@Override @Nullable public Object getValue() throws EvaluationException { if (this.compiledAst != null) { try { EvaluationContext context = getEvaluationContext(); return this.compiledAst.getValue(context.getRootObject().getValue(), context); } catch (Throwable ex) { // If running in mixed mode, revert to interpreted if (this.configuration.getCompilerMode() == SpelCompilerMode.MIXED) { this.interpretedCount = 0; this.compiledAst = null; } else { // Running in SpelCompilerMode.immediate mode - propagate exception to caller throw new SpelEvaluationException(ex, SpelMessage.EXCEPTION_RUNNING_COMPILED_EXPRESSION); } } } ExpressionState expressionState = new ExpressionState(getEvaluationContext(), this.configuration); Object result = this.ast.getValue(expressionState); checkCompile(expressionState); return result; }
@Test public void propertyAccessWithInstanceMethodResolverAndTypedRootObject() { Person target = new Person("p1"); EvaluationContext context = SimpleEvaluationContext.forReadOnlyDataBinding(). withInstanceMethods().withTypedRootObject(target, TypeDescriptor.valueOf(Object.class)).build(); assertEquals("1", parser.parseExpression("name.substring(1)").getValue(context, target)); assertSame(target, context.getRootObject().getValue()); assertSame(Object.class, context.getRootObject().getTypeDescriptor().getType()); }
@Override @Nullable public Object getValue(EvaluationContext context) throws EvaluationException { Assert.notNull(context, "EvaluationContext is required"); if (this.compiledAst != null) { try { return this.compiledAst.getValue(context.getRootObject().getValue(), context); } catch (Throwable ex) { // If running in mixed mode, revert to interpreted if (this.configuration.getCompilerMode() == SpelCompilerMode.MIXED) { this.interpretedCount = 0; this.compiledAst = null; } 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; }
@Test public void propertyReadWriteWithRootObject() { Person target = new Person("p1"); EvaluationContext context = SimpleEvaluationContext.forReadWriteDataBinding().withRootObject(target).build(); assertSame(target, context.getRootObject().getValue()); Expression expr = parser.parseExpression("name"); assertEquals("p1", expr.getValue(context, target)); target.setName("p2"); assertEquals("p2", expr.getValue(context, target)); parser.parseExpression("name='p3'").getValue(context, target); assertEquals("p3", target.getName()); assertEquals("p3", expr.getValue(context, target)); expr.setValue(context, target, "p4"); assertEquals("p4", target.getName()); assertEquals("p4", expr.getValue(context, target)); }
try { EvaluationContext context = getEvaluationContext(); Object result = this.compiledAst.getValue(context.getRootObject().getValue(), context); if (expectedResultType == null) { return (T) result;
Object result = this.compiledAst.getValue(context.getRootObject().getValue(), context); if (expectedResultType != null) { return ExpressionUtils.convertTypedValue(context, new TypedValue(result), expectedResultType);
@Override @Nullable public Object getValue() throws EvaluationException { if (this.compiledAst != null) { try { EvaluationContext context = getEvaluationContext(); return this.compiledAst.getValue(context.getRootObject().getValue(), context); } catch (Throwable ex) { // If running in mixed mode, revert to interpreted if (this.configuration.getCompilerMode() == SpelCompilerMode.MIXED) { this.interpretedCount = 0; this.compiledAst = null; } else { // Running in SpelCompilerMode.immediate mode - propagate exception to caller throw new SpelEvaluationException(ex, SpelMessage.EXCEPTION_RUNNING_COMPILED_EXPRESSION); } } } ExpressionState expressionState = new ExpressionState(getEvaluationContext(), this.configuration); Object result = this.ast.getValue(expressionState); checkCompile(expressionState); return result; }
try { EvaluationContext context = getEvaluationContext(); Object result = this.compiledAst.getValue(context.getRootObject().getValue(), context); if (expectedResultType == null) { return (T) result;
@Override public Object getValue(EvaluationContext context) throws EvaluationException { Object root = context.getRootObject().getValue(); return root == null ? getValue() : getValue(root); }
@Override public Object getValue(EvaluationContext context) throws EvaluationException { Object root = context.getRootObject().getValue(); return root == null ? getValue() : getValue(root); }