01: package org.makumba.forms.html;
02:
03: /**
04: * An ordered set of chooser choices
05: * @author Cristian Bogdan
06: */
07: public class ChoiceSet extends java.util.ArrayList {
08:
09: private static final long serialVersionUID = 1L;
10:
11: public static final String PARAMNAME = "org.makumba.ChoiceSet";
12:
13: public class Choice {
14: Object value;
15:
16: String title;
17:
18: boolean forceSelection;
19:
20: boolean forceDeselection;
21:
22: public Object getValue() {
23: return value;
24: }
25:
26: public String getTitle() {
27: return title;
28: }
29: }
30:
31: java.util.Map<Object, Choice> m = new java.util.HashMap<Object, Choice>();
32:
33: public void add(Object value, String title, boolean forceSelection,
34: boolean forceDeselection) {
35: // only Pointer.Null values can be repeated, rest are ignored
36: // null values are not a choice, they are simply a text between choices
37: if (value != org.makumba.Pointer.Null && value != null
38: && m.get(value) != null)
39: return;
40: Choice c = new Choice();
41: c.value = value;
42: c.title = title;
43: c.forceSelection = forceSelection;
44: c.forceDeselection = forceDeselection;
45: if (value != null)
46: m.put(value, c);
47: add(c);
48: }
49: }
|