01: package com.jeta.forms.store.jml;
02:
03: import java.util.Iterator;
04:
05: import com.jeta.forms.store.jml.dom.JMLDocument;
06: import com.jeta.forms.store.jml.dom.JMLNode;
07: import com.jeta.forms.store.support.PropertyMap;
08:
09: public class PropertyMapSerializer implements JMLSerializer {
10:
11: /**
12: * XMLDeserializer implementation <object> <at name="keyname1">value1</at>
13: * <at name="keyname2">value2</at> <at name="keyname3">value3</at>
14: * </object>
15: */
16: public JMLNode serialize(JMLDocument document, Object obj)
17: throws JMLException {
18: JMLNode hashNode = JMLUtils.createObjectNode(document, obj);
19: PropertyMap pmap = (PropertyMap) obj;
20:
21: if (pmap != null) {
22: Iterator iter = pmap.keySet().iterator();
23: while (iter.hasNext()) {
24: Object key = iter.next();
25: Object value = pmap.get(key);
26: JMLNode propnode = null;
27: if (JMLUtils.isPrimitive(value))
28: propnode = JMLUtils.createPropertyNode(document,
29: key.toString(), value.toString());
30: else
31: propnode = JMLUtils.createPropertyNode(document,
32: key.toString(), value);
33:
34: hashNode.appendChild(propnode);
35: }
36: }
37: return hashNode;
38: }
39:
40: }
|