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

Static Properties 

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 accessing static properties using T operator.

File Name  :  
com/bethecoder/tutorials/spring3/tests/spel/StaticPropertiesTest.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.spring3.tests.spel;

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

public class StaticPropertiesTest {

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

    ExpressionParser parser = new SpelExpressionParser();
    
    //Accessing Static Properties
    int maxValue = parser.parseExpression("T(Integer).MAX_VALUE").getValue(Integer.class);
    System.out.println("Int max value : " + maxValue);

    int minValue = parser.parseExpression("T(Integer).MIN_VALUE").getValue(Integer.class);
    System.out.println("Int min value : " + minValue);

    double piValue = parser.parseExpression("T(Math).PI").getValue(Double.class);
    System.out.println("PI value : " + piValue);
    
  }
}
   

It gives the following output,
Int max value : 2147483647
Int min value : -2147483648
PI value : 3.141592653589793


                    Print

   



Books Recommendation

 
 
bl  br