Package org.springframework.expression

Examples of org.springframework.expression.PropertyAccessor


    if (targetObject == null && this.nullSafe) {
      return TypedValue.NULL;
    }

    PropertyAccessor accessorToUse = this.cachedReadAccessor;
    if (accessorToUse != null) {
      try {
        return accessorToUse.read(eContext, contextObject.getValue(), name);
      }
      catch (AccessException ae) {
        // this is OK - it may have gone stale due to a class change,
        // let's try to get a new one and call it before giving up
        this.cachedReadAccessor = null;
View Full Code Here


   
    if (contextObject.getValue() == null && nullSafe) {
      return;
    }

    PropertyAccessor accessorToUse = this.cachedWriteAccessor;
    if (accessorToUse != null) {
      try {
        accessorToUse.write(eContext, contextObject.getValue(), name, newValue);
        return;
      }
      catch (AccessException ae) {
        // this is OK - it may have gone stale due to a class change,
        // let's try to get a new one and call it before giving up
View Full Code Here

    if (targetObject == null && this.nullSafe) {
      return TypedValue.NULL;
    }

    PropertyAccessor accessorToUse = this.cachedReadAccessor;
    if (accessorToUse != null) {
      try {
        return accessorToUse.read(state.getEvaluationContext(), contextObject.getValue(), name);
      }
      catch (AccessException ae) {
        // this is OK - it may have gone stale due to a class change,
        // let's try to get a new one and call it before giving up
        this.cachedReadAccessor = null;
View Full Code Here

   
    if (contextObject.getValue() == null && nullSafe) {
      return;
    }

    PropertyAccessor accessorToUse = this.cachedWriteAccessor;
    if (accessorToUse != null) {
      try {       
        accessorToUse.write(state.getEvaluationContext(), contextObject.getValue(), name, newValue);
        return;
      }
      catch (AccessException ae) {
        // this is OK - it may have gone stale due to a class change,
        // let's try to get a new one and call it before giving up
View Full Code Here

    if (targetObject == null && nullSafe) {
      return TypedValue.NULL;
    }

    PropertyAccessor accessorToUse = this.cachedReadAccessor;
    if (accessorToUse != null) {
      try {
        return accessorToUse.read(state.getEvaluationContext(), contextObject.getValue(), name);
      }
      catch (AccessException ae) {
        // this is OK - it may have gone stale due to a class change,
        // let's try to get a new one and call it before giving up
        this.cachedReadAccessor = null;
View Full Code Here

   
    if (contextObject.getValue() == null && nullSafe) {
      return;
    }

    PropertyAccessor accessorToUse = this.cachedWriteAccessor;
    if (accessorToUse != null) {
      try {       
        accessorToUse.write(state.getEvaluationContext(), contextObject.getValue(), name, newValue);
        return;
      }
      catch (AccessException ae) {
        // this is OK - it may have gone stale due to a class change,
        // let's try to get a new one and call it before giving up
View Full Code Here

    checkTemplateParsingError("Hello ${", "No ending suffix '}' for expression starting at character 6: ${");
  }

  @Test
  public void accessingNullPropertyViaReflection_SPR5663() throws AccessException {
    PropertyAccessor propertyAccessor = new ReflectivePropertyAccessor();
    EvaluationContext context = TestScenarioCreator.getTestEvaluationContext();
    assertFalse(propertyAccessor.canRead(context, null, "abc"));
    assertFalse(propertyAccessor.canWrite(context, null, "abc"));
    try {
      propertyAccessor.read(context, null, "abc");
      fail("Should have failed with an AccessException");
    }
    catch (AccessException ae) {
      // success
    }
    try {
      propertyAccessor.write(context, null, "abc", "foo");
      fail("Should have failed with an AccessException");
    }
    catch (AccessException ae) {
      // success
    }
View Full Code Here

    EvaluationContext ctx = new StandardEvaluationContext(t);
//    assertTrue(rpr.canRead(ctx, t, "property"));
//    assertEquals("hello",rpr.read(ctx, t, "property").getValue());
//    assertEquals("hello",rpr.read(ctx, t, "property").getValue()); // cached accessor used

    PropertyAccessor optA = rpr.createOptimalAccessor(ctx, t, "property");
    assertTrue(optA.canRead(ctx, t, "property"));
    assertFalse(optA.canRead(ctx, t, "property2"));
    try {
      optA.canWrite(ctx, t, "property");
      fail();
    }
    catch (UnsupportedOperationException uoe) {
      // success
    }
    try {
      optA.canWrite(ctx, t, "property2");
      fail();
    }
    catch (UnsupportedOperationException uoe) {
      // success
    }
    assertEquals("hello",optA.read(ctx, t, "property").getValue());
    assertEquals("hello",optA.read(ctx, t, "property").getValue()); // cached accessor used

    try {
      optA.getSpecificTargetClasses();
      fail();
    }
    catch (UnsupportedOperationException uoe) {
      // success
    }
    try {
      optA.write(ctx,t,"property",null);
      fail();
    }
    catch (UnsupportedOperationException uoe) {
      // success
    }

    optA = rpr.createOptimalAccessor(ctx, t, "field");
    assertTrue(optA.canRead(ctx, t, "field"));
    assertFalse(optA.canRead(ctx, t, "field2"));
    try {
      optA.canWrite(ctx, t, "field");
      fail();
    }
    catch (UnsupportedOperationException uoe) {
      // success
    }
    try {
      optA.canWrite(ctx, t, "field2");
      fail();
    }
    catch (UnsupportedOperationException uoe) {
      // success
    }
    assertEquals(3,optA.read(ctx, t, "field").getValue());
    assertEquals(3,optA.read(ctx, t, "field").getValue()); // cached accessor used

    try {
      optA.getSpecificTargetClasses();
      fail();
    }
    catch (UnsupportedOperationException uoe) {
      // success
    }
    try {
      optA.write(ctx,t,"field",null);
      fail();
    }
    catch (UnsupportedOperationException uoe) {
      // success
    }
View Full Code Here

    if (targetObject == null && nullSafe) {
      return TypedValue.NULL;
    }

    PropertyAccessor accessorToUse = this.cachedReadAccessor;
    if (accessorToUse != null) {
      try {
        return accessorToUse.read(state.getEvaluationContext(), contextObject.getValue(), name);
      }
      catch (AccessException ae) {
        // this is OK - it may have gone stale due to a class change,
        // let's try to get a new one and call it before giving up
        this.cachedReadAccessor = null;
View Full Code Here

   
    if (contextObject.getValue() == null && nullSafe) {
      return;
    }

    PropertyAccessor accessorToUse = this.cachedWriteAccessor;
    if (accessorToUse != null) {
      try {       
        accessorToUse.write(state.getEvaluationContext(), contextObject.getValue(), name, newValue);
        return;
      }
      catch (AccessException ae) {
        // this is OK - it may have gone stale due to a class change,
        // let's try to get a new one and call it before giving up
View Full Code Here

TOP

Related Classes of org.springframework.expression.PropertyAccessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.