01: /*
02: * Created on Dec 18, 2003
03: *
04: * To change the template for this generated file go to
05: * Window>Preferences>Java>Code Generation>Code and Comments
06: */
07: package org.xdev.base.xssl.collection;
08:
09: import java.util.HashMap;
10:
11: import org.xdev.base.xssl.XSSLActionIterator;
12: import org.xdev.base.xssl.XSSLReturn;
13: import org.xdev.base.xssl.XSSLAction;
14:
15: /**
16: * @author AYegorov
17: *
18: * To change the template for this generated type comment go to
19: * Window>Preferences>Java>Code Generation>Code and Comments
20: */
21: public class MapCollection extends XSSLActionIterator {
22: public static final String KEY = "key";
23:
24: private Object returnValue = null;
25:
26: /**
27: * @param id
28: */
29: public MapCollection(String id) {
30: super (id);
31: // XXX Auto-generated constructor stub
32: }
33:
34: /**
35: * @param id
36: * @param properties
37: */
38: public MapCollection(String id, HashMap properties) {
39: super (id, properties);
40: // XXX Auto-generated constructor stub
41: }
42:
43: /* (non-Javadoc)
44: * @see org.xdev.base.xssl.XSSLReturn#getValue()
45: */
46: public Object getObjectValue() {
47:
48: this .logDebug("Returning map object: " + this .returnValue);
49:
50: return this .returnValue;
51: }
52:
53: /* (non-Javadoc)
54: * @see org.xdev.base.xssl.XSSLAction#set()
55: */
56: protected void set() throws Exception {
57: HashMap map = (HashMap) this .getEvaluatedReference();
58:
59: if (map == null) {
60: map = new HashMap();
61: this .setReference(this .getReferenceId(), map);
62: }
63:
64: if (this .hasProperty(MapCollection.KEY)) {
65:
66: String key = this .getProperty(MapCollection.KEY);
67:
68: this .returnValue = map.get(key);
69:
70: this .logDebug("Retrieved object " + key + ": "
71: + this .returnValue);
72: } else {
73: this .returnValue = map;
74: }
75:
76: }
77:
78: /* (non-Javadoc)
79: * @see org.xdev.base.xssl.XSSLActionIterator#invoke(org.xdev.base.xssl.XSSLAction)
80: */
81: protected void invoke(XSSLAction component) throws Exception {
82:
83: this .logDebug("Adding item "
84: + component.getProperty(MapCollection.KEY)
85: + " to map: " + component.getClass());
86:
87: if (this .returnValue instanceof HashMap
88: && component instanceof XSSLReturn) {
89: ((HashMap) this .returnValue).put(component
90: .getProperty(MapCollection.KEY),
91: ((XSSLReturn) component).getObjectValue());
92: }
93: }
94:
95: }
|