tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Spring > Expression Language > Booleans

Booleans 

The Spring Expression Language (SpEL) is a simple and powerful expression language which helps to query and manipulate objects at runtime. The following example shows evaluating some boolean expressions using SpEL.

File Name  :  
com/bethecoder/tutorials/spring3/tests/spel/BooleanTest.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.spring3.tests.spel;

import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;

public class BooleanTest {

  /**
   @param args
   */
  public static void main(String[] args) {

    ExpressionParser parser = new SpelExpressionParser();
    Expression exp = parser.parseExpression("2 > 0");
    Boolean value = exp.getValue(Boolean.class);
    System.out.println(value);

    exp = parser.parseExpression("2 > 6");
    value = exp.getValue(Boolean.class);
    System.out.println(value);
    
    exp = parser.parseExpression("'BTC' == 'BTC'");
    value = exp.getValue(Boolean.class);
    System.out.println(value);
  }

}
   

It gives the following output,
true
false
true



 
  


  
bl  br