01: package de.schlund.pfixcore.example;
02:
03: import java.util.HashMap;
04: import java.util.Iterator;
05:
06: import de.schlund.pfixcore.example.iwrapper.IndexedTest;
07: import de.schlund.pfixcore.generator.IHandler;
08: import de.schlund.pfixcore.generator.IWrapper;
09: import de.schlund.pfixcore.workflow.Context;
10:
11: /**
12: * Describe class IndexedTestHandler here.
13: *
14: *
15: * Created: Mon Jul 11 14:01:39 2005
16: *
17: * @author <a href="mailto:jtl@schlund.de">Jens Lautenbacher</a>
18: * @version 1.0
19: */
20: public class IndexedTestHandler implements IHandler {
21:
22: // Implementation of de.schlund.pfixcore.generator.IHandler
23:
24: public final void handleSubmittedData(final Context context,
25: final IWrapper wrapper) throws Exception {
26: IndexedTest itest = (IndexedTest) wrapper;
27: ContextAdultInfo cai = SampleRes.getContextAdultInfo(context);
28: String[] keys = itest.getKeysValue();
29:
30: HashMap<String, String> inmap = new HashMap<String, String>();
31: for (int i = 0; i < keys.length; i++) {
32: inmap.put(keys[i], itest.getValue(keys[i]));
33: }
34: cai.setIndexedTest(inmap);
35: }
36:
37: public final void retrieveCurrentStatus(final Context context,
38: final IWrapper wrapper) throws Exception {
39: IndexedTest itest = (IndexedTest) wrapper;
40: ContextAdultInfo cai = SampleRes.getContextAdultInfo(context);
41: HashMap<String, String> outmap = cai.getIndexedTest();
42:
43: for (Iterator<String> i = outmap.keySet().iterator(); i
44: .hasNext();) {
45: String key = i.next();
46: if (outmap.get(key) != null) {
47: itest.setValue(outmap.get(key), key);
48: } else {
49: itest.setValue("", key);
50: }
51:
52: }
53: }
54:
55: public final boolean prerequisitesMet(final Context context)
56: throws Exception {
57: return true;
58: }
59:
60: public final boolean isActive(final Context context)
61: throws Exception {
62: return true;
63: }
64:
65: public final boolean needsData(final Context context)
66: throws Exception {
67: return false;
68: }
69:
70: }
|