Package org.springframework.expression

Examples of org.springframework.expression.TypedValue


  @Test
  public void testNegativeBucketSize() throws Exception {
    StandardEvaluationContext context = new StandardEvaluationContext();
    HashMethodExecutor executor = new HashMethodExecutor();
    TypedValue value = executor.execute(context, new Object(), 3, -2);
    assertThat((String) value.getValue(), is("1_hash"));
  }
View Full Code Here


  @Test
  public void testNegativeHashcode() throws Exception {
    StandardEvaluationContext context = new StandardEvaluationContext();
    HashMethodExecutor executor = new HashMethodExecutor();
    TypedValue value = executor.execute(context, new Object(), -9, 2);
    assertThat((String) value.getValue(), is("1_hash"));
  }
View Full Code Here

  @Test
  public void testNegativeHashcodeBucketSizeBigger() throws Exception {
    StandardEvaluationContext context = new StandardEvaluationContext();
    HashMethodExecutor executor = new HashMethodExecutor();
    TypedValue value = executor.execute(context, new Object(), -9, 12);
    assertThat((String) value.getValue(), is("9_hash"));
    value = executor.execute(context, new Object(), -9, 24);
    assertThat((String) value.getValue(), is("9_hash"));
    value = executor.execute(context, new Object(), -9, 27);
    assertThat((String) value.getValue(), is("9_hash"));
  }
View Full Code Here

      if (target instanceof EvaluationContextExtensionAdapter) {
        return lookupPropertyFrom(((EvaluationContextExtensionAdapter) target), name);
      }

      if (adapterMap.containsKey(name)) {
        return new TypedValue(adapterMap.get(name));
      }

      for (EvaluationContextExtensionAdapter extension : adapters) {

        Map<String, Object> properties = extension.getProperties();
View Full Code Here

    private TypedValue lookupPropertyFrom(EvaluationContextExtensionAdapter extension, String name) {

      Object value = extension.getProperties().get(name);

      if (!(value instanceof Function)) {
        return new TypedValue(value);
      }

      Function function = (Function) value;

      try {
        return new TypedValue(function.invoke(new Object[0]));
      } catch (Exception e) {
        throw new SpelEvaluationException(e, SpelMessage.FUNCTION_REFERENCE_CANNOT_BE_INVOKED, name,
            function.getDeclaringClass());
      }
    }
View Full Code Here

     */
    @Override
    public TypedValue execute(EvaluationContext context, Object target, Object... arguments) throws AccessException {

      try {
        return new TypedValue(function.invoke(arguments));
      } catch (Exception e) {
        throw new SpelEvaluationException(e, SpelMessage.FUNCTION_REFERENCE_CANNOT_BE_INVOKED, function.getName(),
            function.getDeclaringClass());
      }
    }
View Full Code Here

  @Override
  public TypedValue read(final EvaluationContext context, final Object target, final String name) {
    Map<String, Object> source = (Map<String, Object>) target;

    Object value = source.get(name);
    return value == null ? TypedValue.NULL : new TypedValue(value);
  }
View Full Code Here

            // AST tree on a different class (Spring internally caches property accessors).
            // So this exception might be considered "normal" by Spring AST evaluator and
            // just use it to refresh the property accessor cache.
            throw new AccessException("Cannot read target of class " + target.getClass().getName());
        }
        return new TypedValue(((VariablesMap<String,?>)target).get(name));
    }
View Full Code Here

            // AST tree on a different class (Spring internally caches property accessors).
            // So this exception might be considered "normal" by Spring AST evaluator and
            // just use it to refresh the property accessor cache.
            throw new AccessException("Cannot read target of class " + target.getClass().getName());
        }
        return new TypedValue(((Beans)target).get(name));
    }
View Full Code Here

            // AST tree on a different class (Spring internally caches property accessors).
            // So this exception might be considered "normal" by Spring AST evaluator and
            // just use it to refresh the property accessor cache.
            throw new AccessException("Cannot read target of class " + target.getClass().getName());
        }
        return new TypedValue(((VariablesMap<String,?>)target).get(name));
    }
View Full Code Here

TOP

Related Classes of org.springframework.expression.TypedValue

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.