1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package net.smartlab.web.poll;
25
26 import java.util.List;
27
28 import net.smartlab.web.Enumeration;
29
30
31
32
33
34 public class Question {
35
36 private long id;
37
38 private String title;
39
40 private String description;
41
42 private Type type;
43
44 private boolean required;
45
46
47
48
49
50
51 private List answers = null;
52
53
54
55
56
57 public long getId() {
58 return id;
59 }
60
61
62
63
64
65 public void setId(long id) {
66 this.id = id;
67 }
68
69
70
71
72
73 public List getAnswers() {
74 return answers;
75 }
76
77
78
79
80
81 public void setAnswers(List answers) {
82 this.answers = answers;
83 }
84
85
86
87
88
89 public void addAnswer(Answer answer) {
90 answers.add(answer);
91 }
92
93
94
95
96
97 public String getDescription() {
98 return description;
99 }
100
101
102
103
104
105 public void setDescription(String description) {
106 this.description = description;
107 }
108
109
110
111
112
113 public String getTitle() {
114 return title;
115 }
116
117
118
119
120
121 public void setTitle(String title) {
122 this.title = title;
123 }
124
125
126
127
128
129 public Type getType() {
130 return type;
131 }
132
133
134
135
136
137 public void setType(Type type) {
138 this.type = type;
139 }
140
141
142
143
144
145 public static class Type extends Enumeration {
146
147 private static final long serialVersionUID = -2830589290044816317L;
148
149
150
151
152 public static final Type OPEN = new Type('O', "poll.type.open");
153
154
155
156
157 public static final Type SINGLE = new Type('S', "poll.type.single");
158
159
160
161
162 public static final Type MULTIPLE = new Type('M', "poll.type.multiple");
163
164
165
166
167 public static final Type[] LIST = new Type[] {SINGLE, MULTIPLE, OPEN};
168
169
170
171
172
173
174 private Type(int id, String display) {
175 super(id, display);
176 }
177
178
179
180
181 public Enumeration decode(int id) {
182 switch (id) {
183 case 'O':
184 return OPEN;
185 case 'S':
186 return SINGLE;
187 case 'M':
188 return MULTIPLE;
189 default:
190 return null;
191 }
192 }
193
194 public Enumeration decode(String code) {
195 return this.decode((int)code.toUpperCase().charAt(0));
196 }
197 }
198 }