Changes

Jump to: navigation, search

Teams Winter 2011/team1/RCP/Create RPC Application

957 bytes added, 16:37, 8 March 2011
Add Model Provider
==== Add Model Provider ====
"ModelProvider" class creates and maintains an ArrayList of Student objects and helps us find an student by it's id from the list of students.<br/>
<code>Student.java </code>
 
<source lang=java>
package cs.ecl.rcp.simplercp.model;
 
import java.util.ArrayList;
import java.util.List;
 
public enum ModelProvider {
INSTANCE;
 
private List<Student> students;
private ModelProvider() {
students = new ArrayList<Student>();
// Data could be retrieved here from database
students.add(new Student("01234567","Ladan", "Zahiroleslam", "CPA"));
students.add(new Student("09876543", "Anastasia", "Semionova", "CPA"));
students.add(new Student("01122334", "Minoo", "Ziaei", "CPA"));
students.add(new Student("02233445", "Sergiu", "Ecob", "CPA"));
}
 
public Student getPersonById(String id) {
for (Student student : students) {
if (student.getId() == id) {
return student;
}
}
return null;
}
 
public List<Student> getStudents() {
return students;
}
 
}
 
</source>
1
edit

Navigation menu