KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > barracuda > examples > xmlc > data > UsersList


1 package org.enhydra.barracuda.examples.xmlc.data;
2
3 import java.util.*;
4
5 /**
6  * This object represents a data model whose state
7  * consists of a list of users and a current position
8  * within that list.
9  */

10 public class UsersList extends ArrayList {
11
12     //the master copy
13
private static UsersList masterTable = null;
14     
15     //local vars
16
private int pos = -1;
17
18     /**
19      * Build the master instance of some Table Data.
20      */

21     public static UsersList getMasterInstance() {
22         if (masterTable==null) masterTable = getSampleInstance();
23         return masterTable;
24     }
25             
26     /**
27      * Update the master copy
28      */

29     public static void setMasterInstance(UsersList itable) {
30         masterTable = itable;
31     }
32     
33     /**
34      * Build a sample instance of some Table Data. THis is
35      * just bogus data used to create a heirarchical data
36      * structure which acts as the true data "model" (in the
37      * abstract sense of the word, not in the MVC sense)
38      */

39     public static UsersList getSampleInstance() {
40         UsersList table = new UsersList();
41         UserData ud = null;
42         
43         ud = new UserData();
44         ud.put(UserData.SELECTED, new Boolean JavaDoc(true));
45         ud.put(UserData.FIRST_NAME, "John");
46         ud.put(UserData.LAST_NAME, "Doe");
47         ud.put(UserData.GENDER, new Boolean JavaDoc(true));
48         ud.put(UserData.AGE, new Integer JavaDoc(35));
49         ud.put(UserData.EMAIL, "JohnD@anonymous.com");
50         ud.put(UserData.PHONE, "831-471-1234");
51         ud.put(UserData.NOTES, "");
52         ud.setNew(false);
53         ud.setDirty(false);
54         table.add(ud);
55
56         ud = new UserData();
57         ud.put(UserData.SELECTED, new Boolean JavaDoc(false));
58         ud.put(UserData.FIRST_NAME, "Jane");
59         ud.put(UserData.LAST_NAME, "Lizmon");
60         ud.put(UserData.GENDER, new Boolean JavaDoc(false));
61         ud.put(UserData.AGE, new Integer JavaDoc(28));
62         ud.put(UserData.EMAIL, "123Lizmon@aol.com");
63         ud.put(UserData.PHONE, "831-471-4321");
64         ud.put(UserData.NOTES, "");
65         ud.setNew(false);
66         ud.setDirty(false);
67         table.add(ud);
68
69         ud = new UserData();
70         ud.put(UserData.SELECTED, new Boolean JavaDoc(true));
71         ud.put(UserData.FIRST_NAME, "William");
72         ud.put(UserData.LAST_NAME, "Rensworth");
73         ud.put(UserData.GENDER, new Boolean JavaDoc(true));
74         ud.put(UserData.AGE, new Integer JavaDoc(17));
75         ud.put(UserData.EMAIL, "willier@mcaw.com");
76         ud.put(UserData.PHONE, "360-413-1556");
77         ud.put(UserData.NOTES, "Hasn't been seen for weeks...");
78         ud.setNew(false);
79         ud.setDirty(false);
80         table.add(ud);
81
82         ud = new UserData();
83         ud.put(UserData.SELECTED, new Boolean JavaDoc(true));
84         ud.put(UserData.FIRST_NAME, "Brian");
85         ud.put(UserData.LAST_NAME, "Switer");
86         ud.put(UserData.GENDER, new Boolean JavaDoc(true));
87         ud.put(UserData.AGE, new Integer JavaDoc(54));
88         ud.put(UserData.EMAIL, "brian.switer@aol.com");
89         ud.put(UserData.PHONE, "831-544-7632");
90         ud.put(UserData.NOTES, "Brian likes to sail yatchs...");
91         ud.setNew(false);
92         ud.setDirty(false);
93         table.add(ud);
94
95         ud = new UserData();
96         ud.put(UserData.SELECTED, new Boolean JavaDoc(false));
97         ud.put(UserData.FIRST_NAME, "Elizabeth");
98         ud.put(UserData.LAST_NAME, "McKormick");
99         ud.put(UserData.GENDER, new Boolean JavaDoc(false));
100         ud.put(UserData.AGE, new Integer JavaDoc(34));
101         ud.put(UserData.EMAIL, "lizzym@yahoo.com");
102         ud.put(UserData.PHONE, "406-731-8856");
103         ud.put(UserData.NOTES, "Loves ballroom dancing");
104         ud.setNew(false);
105         ud.setDirty(false);
106         table.add(ud);
107         
108         ud = new UserData();
109         ud.put(UserData.SELECTED, new Boolean JavaDoc(false));
110         ud.put(UserData.FIRST_NAME, "Sweaty");
111         ud.put(UserData.LAST_NAME, "Muggeridge");
112         ud.put(UserData.GENDER, new Boolean JavaDoc(true));
113         ud.put(UserData.AGE, new Integer JavaDoc(47));
114         ud.put(UserData.EMAIL, "sm@pigiron.com");
115         ud.put(UserData.PHONE, "312-435-4487");
116         ud.put(UserData.NOTES, "");
117         ud.setNew(false);
118         ud.setDirty(false);
119         table.add(ud);
120         
121         ud = new UserData();
122         ud.put(UserData.SELECTED, new Boolean JavaDoc(false));
123         ud.put(UserData.FIRST_NAME, "Lawrence");
124         ud.put(UserData.LAST_NAME, "Welkomich");
125         ud.put(UserData.GENDER, new Boolean JavaDoc(true));
126         ud.put(UserData.AGE, new Integer JavaDoc(132));
127         ud.put(UserData.EMAIL, "lw@letsapolka.com");
128         ud.put(UserData.PHONE, "944-633-1524");
129         ud.put(UserData.NOTES, "What is there to say...");
130         ud.setNew(false);
131         ud.setDirty(false);
132         table.add(ud);
133         
134         ud = new UserData();
135         ud.put(UserData.SELECTED, new Boolean JavaDoc(true));
136         ud.put(UserData.FIRST_NAME, "Gerhardus");
137         ud.put(UserData.LAST_NAME, "Voss");
138         ud.put(UserData.GENDER, new Boolean JavaDoc(true));
139         ud.put(UserData.AGE, new Integer JavaDoc(132));
140         ud.put(UserData.EMAIL, "gerhardusv@wts.edu");
141         ud.put(UserData.PHONE, "755-413-8973");
142         ud.put(UserData.NOTES, "");
143         ud.setNew(false);
144         ud.setDirty(false);
145         table.add(ud);
146         
147         return table;
148     }
149     
150     /**
151      * Set the current pos
152      */

153     public void setCurrentPos(int ipos) {
154         pos = ipos;
155     }
156     
157     /**
158      * Get the current pos
159      */

160     public int getCurrentPos() {
161         return pos;
162     }
163     
164 }
165
166
Popular Tags