package com.lgg.ognl.testdao;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
import com.lgg.ognl.test.SClass;
import com.lgg.ognl.test.School;
import com.lgg.ognl.test.Student;
import ognl.Ognl;
import ognl.OgnlException;
public class OgnlTest2 {
public static void main(String[] args) throws OgnlException, ParseException {
// TODO Auto-generated method stub
//test();
test2();
}
public static void test() throws OgnlException{
School school1=new School();
SClass java1=new SClass();
java1.setCname("java 01");
SClass java2=new SClass();
java2.setCname("java 02");
List<SClass> classes= new ArrayList<SClass>();
classes.add(java1);
classes.add(java2);
school1.setClasses(classes);
Object object=Ognl.getValue("classes.{cname}", school1);
System.out.println(object);
}
public static void test2() throws ParseException, OgnlException{
SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
Student s=new Student("zhansan", 23.0f,format.parse("2013-03-04") , null, 90);
Student s2=new Student("lisi", 20.0f,format.parse("2005-07-04") , null, 80);
Student s3=new Student("zhaosi", 22.0f,format.parse("2004-06-04") , null, 88);
List<Student> m=new ArrayList<Student>();
m.add(s);
m.add(s2);
m.add(s3);
SClass cla=new SClass();
Ognl.setValue("students", cla, m);
Scanner sc =new Scanner(System.in);
int temp=sc.nextInt();
Iterator<String> it= (Iterator<String>) Ognl.getValue("students.{?#this.scores>="+temp+"}.{sname}.iterator", cla);
while(it.hasNext()){
System.out.println(it.next());
}
/* ArrayList list = (ArrayList) Ognl.getValue("students.{?#this.scores>="+temp+"}", cla);
for (int i = 0; i < list.size(); i++) {
Student stu =(Student) list.get(i);
System.out.println(stu.getSname()+" "+stu.getAge()
+" "+format.format(stu.getBday())
+" "+stu.getScores());
}*/
}
}
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
import com.lgg.ognl.test.SClass;
import com.lgg.ognl.test.School;
import com.lgg.ognl.test.Student;
import ognl.Ognl;
import ognl.OgnlException;
public class OgnlTest2 {
public static void main(String[] args) throws OgnlException, ParseException {
// TODO Auto-generated method stub
//test();
test2();
}
public static void test() throws OgnlException{
School school1=new School();
SClass java1=new SClass();
java1.setCname("java 01");
SClass java2=new SClass();
java2.setCname("java 02");
List<SClass> classes= new ArrayList<SClass>();
classes.add(java1);
classes.add(java2);
school1.setClasses(classes);
Object object=Ognl.getValue("classes.{cname}", school1);
System.out.println(object);
}
public static void test2() throws ParseException, OgnlException{
SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
Student s=new Student("zhansan", 23.0f,format.parse("2013-03-04") , null, 90);
Student s2=new Student("lisi", 20.0f,format.parse("2005-07-04") , null, 80);
Student s3=new Student("zhaosi", 22.0f,format.parse("2004-06-04") , null, 88);
List<Student> m=new ArrayList<Student>();
m.add(s);
m.add(s2);
m.add(s3);
SClass cla=new SClass();
Ognl.setValue("students", cla, m);
Scanner sc =new Scanner(System.in);
int temp=sc.nextInt();
Iterator<String> it= (Iterator<String>) Ognl.getValue("students.{?#this.scores>="+temp+"}.{sname}.iterator", cla);
while(it.hasNext()){
System.out.println(it.next());
}
/* ArrayList list = (ArrayList) Ognl.getValue("students.{?#this.scores>="+temp+"}", cla);
for (int i = 0; i < list.size(); i++) {
Student stu =(Student) list.get(i);
System.out.println(stu.getSname()+" "+stu.getAge()
+" "+format.format(stu.getBday())
+" "+stu.getScores());
}*/
}
}