01: package com.jeta.forms.store.jml;
02:
03: import com.jeta.forms.store.jml.dom.JMLDocument;
04: import com.jeta.forms.store.jml.dom.JMLNode;
05:
06: /**
07: * Serializer for Object[] types.
08: */
09: public class ObjectArraySerializer implements JMLSerializer {
10:
11: /**
12: * XMLSeserializer implementation <object classname="[Ljava.lang.Object;">
13: * <at name="item"> <object>,,,</object> </at> <at name="item"> <object>,,,</object>
14: * </at> </object>
15: */
16: public JMLNode serialize(JMLDocument document, Object obj)
17: throws JMLException {
18:
19: JMLUtils.verifyObjectType(obj, Object[].class);
20:
21: JMLNode node = JMLUtils.createObjectNode(document, obj);
22: Object[] oa = (Object[]) obj;
23:
24: if (oa != null) {
25: for (int index = 0; index < oa.length; index++) {
26: Object item = oa[index];
27: if (item != null) {
28: JMLNode itemNode = JMLUtils.createPropertyNode(
29: document, "item", JMLUtils
30: .getPrimitiveHolder(item));
31: itemNode.setAttribute("index", String
32: .valueOf(index));
33: node.appendChild(itemNode);
34: }
35: }
36: node.setAttribute("size", String.valueOf(oa.length));
37: }
38: return node;
39: }
40:
41: }
|