public List<PropertyAccessor> getPropertyAccessors() { return this.relatedContext.getPropertyAccessors(); }
public List<PropertyAccessor> getPropertyAccessors() { return this.relatedContext.getPropertyAccessors(); }
public boolean isWritableProperty(String name, TypedValue contextObject, EvaluationContext evalContext) throws EvaluationException { Object value = contextObject.getValue(); if (value != null) { List<PropertyAccessor> accessorsToTry = getPropertyAccessorsToTry(contextObject.getValue(), evalContext.getPropertyAccessors()); for (PropertyAccessor accessor : accessorsToTry) { try { if (accessor.canWrite(evalContext, value, name)) { return true; } } catch (AccessException ex) { // let others try } } } return false; }
@Override public void setValue(@Nullable Object newValue) { Class<?> contextObjectClass = getObjectClass(this.targetObject); try { if (Indexer.this.cachedWriteName != null && Indexer.this.cachedWriteName.equals(this.name) && Indexer.this.cachedWriteTargetType != null && Indexer.this.cachedWriteTargetType.equals(contextObjectClass)) { // It is OK to use the cached accessor PropertyAccessor accessor = Indexer.this.cachedWriteAccessor; Assert.state(accessor != null, "No cached write accessor"); accessor.write(this.evaluationContext, this.targetObject, this.name, newValue); return; } List<PropertyAccessor> accessorsToTry = AstUtils.getPropertyAccessorsToTry( contextObjectClass, this.evaluationContext.getPropertyAccessors()); for (PropertyAccessor accessor : accessorsToTry) { if (accessor.canWrite(this.evaluationContext, this.targetObject, this.name)) { Indexer.this.cachedWriteName = this.name; Indexer.this.cachedWriteTargetType = contextObjectClass; Indexer.this.cachedWriteAccessor = accessor; accessor.write(this.evaluationContext, this.targetObject, this.name, newValue); return; } } } catch (AccessException ex) { throw new SpelEvaluationException(getStartPosition(), ex, SpelMessage.EXCEPTION_DURING_PROPERTY_WRITE, this.name, ex.getMessage()); } }
targetObjectRuntimeClass, this.evaluationContext.getPropertyAccessors()); for (PropertyAccessor accessor : accessorsToTry) { if (accessor.canRead(this.evaluationContext, this.targetObject, this.name)) {
public boolean isWritableProperty(String name, TypedValue contextObject, EvaluationContext evalContext) throws EvaluationException { Object value = contextObject.getValue(); if (value != null) { List<PropertyAccessor> accessorsToTry = getPropertyAccessorsToTry(contextObject.getValue(), evalContext.getPropertyAccessors()); for (PropertyAccessor accessor : accessorsToTry) { try { if (accessor.canWrite(evalContext, value, name)) { return true; } } catch (AccessException ex) { // let others try } } } return false; }
@Override public void setValue(@Nullable Object newValue) { Class<?> contextObjectClass = getObjectClass(this.targetObject); try { if (Indexer.this.cachedWriteName != null && Indexer.this.cachedWriteName.equals(this.name) && Indexer.this.cachedWriteTargetType != null && Indexer.this.cachedWriteTargetType.equals(contextObjectClass)) { // It is OK to use the cached accessor PropertyAccessor accessor = Indexer.this.cachedWriteAccessor; Assert.state(accessor != null, "No cached write accessor"); accessor.write(this.evaluationContext, this.targetObject, this.name, newValue); return; } List<PropertyAccessor> accessorsToTry = AstUtils.getPropertyAccessorsToTry( contextObjectClass, this.evaluationContext.getPropertyAccessors()); for (PropertyAccessor accessor : accessorsToTry) { if (accessor.canWrite(this.evaluationContext, this.targetObject, this.name)) { Indexer.this.cachedWriteName = this.name; Indexer.this.cachedWriteTargetType = contextObjectClass; Indexer.this.cachedWriteAccessor = accessor; accessor.write(this.evaluationContext, this.targetObject, this.name, newValue); return; } } } catch (AccessException ex) { throw new SpelEvaluationException(getStartPosition(), ex, SpelMessage.EXCEPTION_DURING_PROPERTY_WRITE, this.name, ex.getMessage()); } }
@Test public void testPropertyAccessors() { ExpressionState state = getState(); assertEquals(state.getEvaluationContext().getPropertyAccessors(), state.getPropertyAccessors()); }
if (evalContext.getPropertyAccessors().contains(accessorToUse)) { try { accessorToUse.write(evalContext, contextObject.getValue(), name, newValue); getPropertyAccessorsToTry(contextObject.getValue(), evalContext.getPropertyAccessors()); try { for (PropertyAccessor accessor : accessorsToTry) {
if (evalContext.getPropertyAccessors().contains(accessorToUse)) { try { return accessorToUse.read(evalContext, contextObject.getValue(), name); getPropertyAccessorsToTry(contextObject.getValue(), evalContext.getPropertyAccessors());
targetObjectRuntimeClass, this.evaluationContext.getPropertyAccessors()); for (PropertyAccessor accessor : accessorsToTry) { if (accessor.canRead(this.evaluationContext, this.targetObject, this.name)) {
if (evalContext.getPropertyAccessors().contains(accessorToUse)) { try { accessorToUse.write(evalContext, contextObject.getValue(), name, newValue); getPropertyAccessorsToTry(contextObject.getValue(), evalContext.getPropertyAccessors()); try { for (PropertyAccessor accessor : accessorsToTry) {
if (evalContext.getPropertyAccessors().contains(accessorToUse)) { try { return accessorToUse.read(evalContext, contextObject.getValue(), name); getPropertyAccessorsToTry(contextObject.getValue(), evalContext.getPropertyAccessors());
public List<PropertyAccessor> getPropertyAccessors() { return delegate.getPropertyAccessors(); }
public List<PropertyAccessor> getPropertyAccessors() { return this.propertyAccessors == null ? this.delegate.getPropertyAccessors() : this.propertyAccessors; }
@Override public List<PropertyAccessor> getPropertyAccessors() { return this.delegate.getPropertyAccessors(); }
public List<PropertyAccessor> getPropertyAccessors() { return this.propertyAccessors == null ? this.delegate.getPropertyAccessors() : this.propertyAccessors; }
public List<PropertyAccessor> getPropertyAccessors() { return this.propertyAccessors == null ? this.delegate.getPropertyAccessors() : this.propertyAccessors; }
public List<PropertyAccessor> getPropertyAccessors() { return this.propertyAccessors == null ? this.delegate.getPropertyAccessors() : this.propertyAccessors; }
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); 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);