01: /*
02: * Created on Nov 23, 2004
03: */
04: package uk.org.ponder.rsf.request;
05:
06: import java.io.Serializable;
07: import java.util.ArrayList;
08: import java.util.HashMap;
09: import java.util.List;
10:
11: /**
12: * @author Antranig Basman (antranig@caret.cam.ac.uk)
13: *
14: */
15: public class RequestSubmittedValueCache implements Serializable {
16: public void addEntry(SubmittedValueEntry sve) {
17: if (sve.componentid != null) {
18: idmap.put(sve.componentid, sve);
19: }
20: pathmap.put(sve.valuebinding, sve);
21: entries.add(sve);
22: }
23:
24: /** Used by RSVCFixer to fix up component values in view tree just
25: * after production, and just before rendering, in the case this is
26: * an erroneous submission being returned to the user.
27: */
28: public SubmittedValueEntry byID(String componentid) {
29: return (SubmittedValueEntry) idmap.get(componentid);
30: }
31:
32: /** Used so that we can fixup errors from this submission, which are
33: * generated referring to bean paths, back onto component IDs.
34: */
35: public SubmittedValueEntry byPath(String beanpath) {
36: return (SubmittedValueEntry) pathmap.get(beanpath);
37: }
38:
39: private HashMap idmap = new HashMap();
40: private HashMap pathmap = new HashMap();
41: /** The list of entries, in order of application.
42: */
43: private List entries = new ArrayList();
44:
45: public int getEntries() {
46: return entries.size();
47: }
48:
49: public SubmittedValueEntry entryAt(int i) {
50: return (SubmittedValueEntry) entries.get(i);
51: }
52:
53: public RequestSubmittedValueCache copy() {
54: RequestSubmittedValueCache togo = new RequestSubmittedValueCache();
55: for (int i = 0; i < entries.size(); ++i) {
56: togo.addEntry(entryAt(i));
57: }
58: return togo;
59: }
60: }
|