OGNL Part 6: Selection
In the part 5 of this series, we’ve discussed the Projection concept. In this part, see the example for the selection which is very similar to concept of SQL selection.
package au.com.ojitha.ongl;
import java.util.List;
import ognl.Ognl;
import ognl.OgnlException;
public class ProjectingExmaple {
/**
* @param args
* @throws OgnlException
*/
public static void main(String[] args) throws OgnlException {
List<Integer> classes =(List<Integer>)Ognl.getValue("array.{? #this > 2}", new MyRoot());
for (Integer class1 : classes) {
System.out.println(class1);
}
System.out.println("size of the output "+classes.size());
}
}
class MyRoot {
private int[] array = {1,2,3,4};
public int[] getArray() {
return array;
}
public void setArray(int[] array) {
this.array = array;
}
}
Here the output
3 4 size of the output 2
Reference
OGNL language guide for more information.
Comments
Post a Comment
commented your blog