01: /*
02: @COPYRIGHT@
03: */
04: package demo.tasklist.service;
05:
06: import java.util.ArrayList;
07:
08: /**
09: * DataKeeper keeps track of the current state of the task list. All
10: * modifications to the task list are made by calling DataKeeper's methods.
11: */
12: public class DataKeeper {
13:
14: private ArrayList userList;
15:
16: public DataKeeper() {
17: userList = new ArrayList();
18: }
19:
20: public void addListItem(String newListItem) {
21: if (newListItem != null) {
22: userList.add(newListItem);
23: }
24: }
25:
26: public void deleteListItems(String[] itemsForDelete) {
27: if (itemsForDelete != null) {
28: for (int i = 0; i < itemsForDelete.length; i++) {
29: userList.remove(itemsForDelete[i]);
30: }
31: }
32: }
33:
34: public int getListSize() {
35: if (userList == null) {
36: return 0;
37: }
38: return userList.size();
39: }
40:
41: public String getListItem(int index) {
42: return (String) userList.get(index);
43: }
44:
45: public ArrayList getList() {
46: return userList;
47: }
48:
49: }
|