01 /**
02 *
03 * All content copyright (c) 2003-2008 Terracotta, Inc.,
04 * except as may otherwise be noted in a separate copyright notice.
05 * All rights reserved.
06 *
07 */
08 package demo.tasklist.service;
09
10 import java.util.ArrayList;
11
12 /**
13 * DataKeeper keeps track of the current state of the task list. All
14 * modifications to the task list are made by calling DataKeeper's methods.
15 *
16 *@author Terracotta, Inc.
17 */
18 public class DataKeeper {
19
20 private ArrayList userList;
21
22 public DataKeeper() {
23 userList = new ArrayList();
24 }
25
26 public int getListSize() {
27 if (userList == null) {
28 return 0;
29 }
30 return userList.size();
31 }
32
33 public String getListItem(int index) {
34 return (String) userList.get(index);
35 }
36
37 public ArrayList getList() {
38 return userList;
39 }
40
41 public void addListItem(String newListItem) {
42 if (newListItem != null) {
43 userList.add(newListItem);
44 }
45 }
46
47 public void deleteListItems(String[] itemsForDelete) {
48 if (itemsForDelete != null) {
49 for (int i = 0; i < itemsForDelete.length; i++) {
50 userList.remove(itemsForDelete[i]);
51 }
52 }
53 }
54
55 }
|