@Override public void setValue(@Nullable Object newValue) { this.evaluationContext.setVariable(this.name, newValue); }
public ExpressionState(EvaluationContext context, SpelParserConfiguration configuration) { this(context, context.getRootObject(), configuration); }
public Class<?> findType(String type) throws EvaluationException { return this.relatedContext.getTypeLocator().findType(type); }
public TypedValue lookupVariable(String name) { Object value = this.relatedContext.lookupVariable(name); return (value != null ? new TypedValue(value) : TypedValue.NULL); }
TypeConverter typeConverter = context.getTypeConverter(); Class<?> type = context.getTypeLocator().findType(typeName); Constructor<?>[] ctors = type.getConstructors();
public TypeConverter getTypeConverter() { return this.relatedContext.getTypeConverter(); }
public List<PropertyAccessor> getPropertyAccessors() { return this.relatedContext.getPropertyAccessors(); }
public TypeComparator getTypeComparator() { return this.relatedContext.getTypeComparator(); }
@Override public TypedValue getValueInternal(ExpressionState state) throws EvaluationException { BeanResolver beanResolver = state.getEvaluationContext().getBeanResolver(); if (beanResolver == null) { throw new SpelEvaluationException( getStartPosition(), SpelMessage.NO_BEAN_RESOLVER_REGISTERED, this.beanName); } try { return new TypedValue(beanResolver.resolve(state.getEvaluationContext(), this.beanName)); } catch (AccessException ex) { throw new SpelEvaluationException(getStartPosition(), ex, SpelMessage.EXCEPTION_DURING_BEAN_RESOLUTION, this.beanName, ex.getMessage()); } }
assertThat((Method) jsonPath, Matchers.not(Matchers.isOneOf(JsonPathUtils.class.getMethods()))); assertEquals(3, evalContexts.size()); assertSame(evalContexts.get(0).getBeanResolver(), evalContexts.get(1).getBeanResolver()); List<PropertyAccessor> propertyAccessors = evalContexts.get(0).getPropertyAccessors(); assertEquals(4, propertyAccessors.size()); PropertyAccessor parentPropertyAccessorOverride = parent.getBean("jsonPropertyAccessor", PropertyAccessor.class); assertTrue(variables.containsKey("jsonPath")); assertNotSame(evalContexts.get(1).getBeanResolver(), evalContexts.get(2).getBeanResolver()); propertyAccessors = evalContexts.get(1).getPropertyAccessors(); assertEquals(4, propertyAccessors.size()); assertTrue(propertyAccessors.contains(parentPropertyAccessorOverride)); assertTrue(variables.containsKey("jsonPath")); propertyAccessors = evalContexts.get(2).getPropertyAccessors(); assertEquals(4, propertyAccessors.size()); PropertyAccessor childPropertyAccessor = child.getBean("jsonPropertyAccessor", PropertyAccessor.class);
public TypedValue lookupVariable(String name) { Object value = this.relatedContext.lookupVariable(name); return (value != null ? new TypedValue(value) : TypedValue.NULL); }
TypeConverter typeConverter = context.getTypeConverter(); Class<?> type = context.getTypeLocator().findType(typeName); Constructor<?>[] ctors = type.getConstructors();
public Object convertValue(Object value, TypeDescriptor targetTypeDescriptor) throws EvaluationException { Object result = this.relatedContext.getTypeConverter().convertValue( value, TypeDescriptor.forObject(value), targetTypeDescriptor); if (result == null) { throw new IllegalStateException("Null conversion result for value [" + value + "]"); } return result; }
public List<PropertyAccessor> getPropertyAccessors() { return this.relatedContext.getPropertyAccessors(); }
public TypeComparator getTypeComparator() { return this.relatedContext.getTypeComparator(); }
@Override public TypedValue getValueInternal(ExpressionState state) throws EvaluationException { BeanResolver beanResolver = state.getEvaluationContext().getBeanResolver(); if (beanResolver == null) { throw new SpelEvaluationException( getStartPosition(), SpelMessage.NO_BEAN_RESOLVER_REGISTERED, this.beanName); } try { return new TypedValue(beanResolver.resolve(state.getEvaluationContext(), this.beanName)); } catch (AccessException ex) { throw new SpelEvaluationException(getStartPosition(), ex, SpelMessage.EXCEPTION_DURING_BEAN_RESOLUTION, this.beanName, ex.getMessage()); } }
public void setVariable(String name, @Nullable Object value) { this.relatedContext.setVariable(name, value); }
public ExpressionState(EvaluationContext context, SpelParserConfiguration configuration) { this(context, context.getRootObject(), configuration); }
public Class<?> findType(String type) throws EvaluationException { return this.relatedContext.getTypeLocator().findType(type); }
private Object findFilterTarget(String filterTargetName, EvaluationContext ctx, MethodInvocation mi) { Object filterTarget = null; if (filterTargetName.length() > 0) { filterTarget = ctx.lookupVariable(filterTargetName); if (filterTarget == null) { throw new IllegalArgumentException( "Filter target was null, or no argument with name " + filterTargetName + " found in method"); } } else if (mi.getArguments().length == 1) { Object arg = mi.getArguments()[0]; if (arg.getClass().isArray() || arg instanceof Collection<?>) { filterTarget = arg; } if (filterTarget == null) { throw new IllegalArgumentException( "A PreFilter expression was set but the method argument type" + arg.getClass() + " is not filterable"); } } if (filterTarget.getClass().isArray()) { throw new IllegalArgumentException( "Pre-filtering on array types is not supported. " + "Using a Collection will solve this problem"); } return filterTarget; }