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

Inline Lists 

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 creating inline lists using SpEL.

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

import java.util.List;

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

public class InlineListTest {

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

    ExpressionParser parser = new SpelExpressionParser();
    
    List numbers = parser.parseExpression("{1, 2, 3, 4, 5, 6}").getValue(List.class);
    System.out.println(numbers);

    List strings = parser.parseExpression("{'one', 'two', 'three', 'four'}").getValue(List.class);
    System.out.println(strings);

    List listOfLists = (Listparser.parseExpression("{{'a','b', 'c'},{'d','e', 'f'}}").getValue()
    System.out.println(listOfLists);
  }

}
   

It gives the following output,
[1, 2, 3, 4, 5, 6]
[one, two, three, four]
[[a, b, c], [d, e, f]]



 
  


  
bl  br