Tabnine Logo
Expression.getValue
Code IndexAdd Tabnine to your IDE (free)

How to use
getValue
method
in
org.springframework.expression.Expression

Best Java code snippets using org.springframework.expression.Expression.getValue (Showing top 20 results out of 2,160)

origin: spring-projects/spring-framework

@Override
public String getValue(Object rootObject) throws EvaluationException {
  StringBuilder sb = new StringBuilder();
  for (Expression expression : this.expressions) {
    String value = expression.getValue(rootObject, String.class);
    if (value != null) {
      sb.append(value);
    }
  }
  return sb.toString();
}
origin: spring-projects/spring-framework

@Test
public void indexIntoPropertyContainingListOfList() {
  List<List<Integer>> property = new ArrayList<>();
  property.add(Arrays.asList(3));
  this.parameterizedListOfList = property;
  SpelExpressionParser parser = new SpelExpressionParser();
  Expression expression = parser.parseExpression("parameterizedListOfList[0]");
  assertEquals("java.util.Arrays$ArrayList<java.lang.Integer>", expression.getValueTypeDescriptor(this).toString());
  assertEquals(property.get(0), expression.getValue(this));
  expression = parser.parseExpression("parameterizedListOfList[0][0]");
  assertEquals(3, expression.getValue(this));
}
origin: spring-projects/spring-framework

@Test
public void testOtherOperators() throws Exception {
  // evaluates to false
  boolean falseValue = parser.parseExpression("'xyz' instanceof T(int)").getValue(Boolean.class);
  assertFalse(falseValue);
  // evaluates to true
  boolean trueValue = parser.parseExpression("'5.00' matches '^-?\\d+(\\.\\d{2})?$'").getValue(Boolean.class);
  assertTrue(trueValue);
  //evaluates to false
  falseValue = parser.parseExpression("'5.0067' matches '^-?\\d+(\\.\\d{2})?$'").getValue(Boolean.class);
  assertFalse(falseValue);
}
origin: spring-projects/spring-framework

@SuppressWarnings("unchecked")
@Test
public void resolveCollectionElementType() {
  listNotGeneric = new ArrayList(2);
  listNotGeneric.add(5);
  listNotGeneric.add(6);
  SpelExpressionParser parser = new SpelExpressionParser();
  Expression expression = parser.parseExpression("listNotGeneric");
  assertEquals("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.ArrayList<?>", expression.getValueTypeDescriptor(this).toString());
  assertEquals("5,6", expression.getValue(this, String.class));
}
origin: spring-projects/spring-framework

@Test
public void ternaryWithBooleanReturn_SPR12271() {
  expression = parser.parseExpression("T(Boolean).TRUE?'abc':'def'");
  assertEquals("abc", expression.getValue());
  assertCanCompile(expression);
  assertEquals("abc", expression.getValue());
  expression = parser.parseExpression("T(Boolean).FALSE?'abc':'def'");
  assertEquals("def", expression.getValue());
  assertCanCompile(expression);
  assertEquals("def", expression.getValue());
}
origin: spring-projects/spring-framework

@Test
public void indexIntoPropertyContainingList() {
  List<Integer> property = new ArrayList<>();
  property.add(3);
  this.parameterizedList = property;
  SpelExpressionParser parser = new SpelExpressionParser();
  Expression expression = parser.parseExpression("parameterizedList");
  assertEquals("java.util.ArrayList<java.lang.Integer>", expression.getValueTypeDescriptor(this).toString());
  assertEquals(property, expression.getValue(this));
  expression = parser.parseExpression("parameterizedList[0]");
  assertEquals(3, expression.getValue(this));
}
origin: spring-projects/spring-framework

@Test
public void testResolvingString() {
  Class<?> stringClass = parser.parseExpression("T(String)").getValue(Class.class);
  assertEquals(String.class, stringClass);
}
origin: spring-projects/spring-framework

@Test
public void emptyList() {
  listOfScalarNotGeneric = new ArrayList();
  SpelExpressionParser parser = new SpelExpressionParser();
  Expression expression = parser.parseExpression("listOfScalarNotGeneric");
  assertEquals("java.util.ArrayList<?>", expression.getValueTypeDescriptor(this).toString());
  assertEquals("", expression.getValue(this, String.class));
}
origin: spring-projects/spring-framework

@Test
public void methodReference_simpleInstanceMethodOneArgReturnPrimitive2() throws Exception {
  expression = parser.parseExpression("charAt(2)");
  char resultI = expression.getValue("abc", Character.TYPE);
  assertEquals('c', resultI);
  assertCanCompile(expression);
  char resultC = expression.getValue("abc", Character.TYPE);
  assertEquals('c', resultC);
}
origin: spring-projects/spring-framework

@Test
public void testAccessingPropertyOfClass() {
  Expression expression = parser.parseExpression("name");
  Object value = expression.getValue(new StandardEvaluationContext(String.class));
  assertEquals("java.lang.String", value);
}
origin: spring-projects/spring-framework

@Test(expected = SpelEvaluationException.class)
public void noGetClassAccess() {
  EvaluationContext context = SimpleEvaluationContext.forReadOnlyDataBinding().build();
  parser.parseExpression("'a'.class.name").getValue(context);
}
origin: spring-projects/spring-framework

@Test
@SuppressWarnings("unchecked")
public void SPR11494() {
  Expression exp = new SpelExpressionParser().parseExpression("T(java.util.Arrays).asList('a','b')");
  List<String> list = (List<String>) exp.getValue();
  assertThat(list.size(), is(2));
}
origin: spring-projects/spring-framework

@Test
public void methodReference_literalArguments_int() throws Exception {
  Expression expression = parser.parseExpression("'abcd'.substring(1,3)");
  String resultI = expression.getValue(new TestClass1(), String.class);
  assertCanCompile(expression);
  String resultC = expression.getValue(new TestClass1(), String.class);
  assertEquals("bc", resultI);
  assertEquals("bc", resultC);
}
origin: spring-projects/spring-framework

@Test
public void SPR9486_subtractFloatWithDouble() {
  Number expectedNumber = 10.21f - 10.2;
  ExpressionParser parser = new SpelExpressionParser();
  StandardEvaluationContext context = new StandardEvaluationContext();
  Expression expression = parser.parseExpression("10.21f - 10.2");
  Number result = expression.getValue(context, null, Number.class);
  assertEquals(expectedNumber, result);
}
origin: spring-projects/spring-framework

@Test
public void SPR9486_floatLessThanOrEqualFloat() {
  Boolean expectedNumber = -10.21f <= -10.22f;
  ExpressionParser parser = new SpelExpressionParser();
  StandardEvaluationContext context = new StandardEvaluationContext();
  Expression expression = parser.parseExpression("-10.21f <= -10.22f");
  Boolean result = expression.getValue(context, null, Boolean.class);
  assertEquals(expectedNumber, result);
}
origin: spring-projects/spring-framework

@Test
public void SPR10210() {
  StandardEvaluationContext context = new StandardEvaluationContext();
  context.setVariable("bridgeExample", new org.springframework.expression.spel.spr10210.D());
  Expression parseExpression = parser.parseExpression("#bridgeExample.bridgeMethod()");
  parseExpression.getValue(context);
}
origin: spring-projects/spring-framework

@Test
public void nullLiteral() throws Exception {
  expression = parser.parseExpression("null");
  Object resultI = expression.getValue(new TestClass1(), Object.class);
  assertCanCompile(expression);
  Object resultC = expression.getValue(new TestClass1(), Object.class);
  assertEquals(null, resultI);
  assertEquals(null, resultC);
  assertEquals(null, resultC);
}
origin: spring-projects/spring-framework

@Test
@SuppressWarnings("rawtypes")
public void SPR12522() {
  SpelExpressionParser parser = new SpelExpressionParser();
  Expression expression = parser.parseExpression("T(java.util.Arrays).asList('')");
  Object value = expression.getValue();
  assertTrue(value instanceof List);
  assertTrue(((List) value).isEmpty());
}
origin: spring-projects/spring-framework

private void checkTemplateParsing(String expression, ParserContext context, String expectedValue) {
  SpelExpressionParser parser = new SpelExpressionParser();
  Expression expr = parser.parseExpression(expression, context);
  assertEquals(expectedValue, expr.getValue(TestScenarioCreator.getTestEvaluationContext()));
}
origin: spring-projects/spring-framework

@Test
public void SPR11609() {
  StandardEvaluationContext sec = new StandardEvaluationContext();
  sec.addPropertyAccessor(new MapAccessor());
  Expression exp = new SpelExpressionParser().parseExpression(
      "T(org.springframework.expression.spel.SpelReproTests$MapWithConstant).X");
  assertEquals(1, exp.getValue(sec));
}
org.springframework.expressionExpressiongetValue

Javadoc

Evaluate this expression in the default standard context.

Popular methods of Expression

  • getExpressionString
    Return the original string used to create this expression (unmodified).
  • setValue
    Set this expression in the provided context to the value provided. The supplied root object override
  • getValueType
    Return the most general type that can be passed to the #setValue(EvaluationContext,Object,Object) me
  • getValueTypeDescriptor
    Return the most general type that can be passed to the #setValue(EvaluationContext,Object,Object) me
  • isWritable
    Determine if an expression can be written to, i.e. setValue() can be called. The supplied root objec

Popular in Java

  • Updating database using SQL prepared statement
  • startActivity (Activity)
  • runOnUiThread (Activity)
  • onRequestPermissionsResult (Fragment)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • JButton (javax.swing)
  • JTable (javax.swing)
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now