comparison m-toolbox/classes/@param/attachToDom.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1
2 function collectedHist = attachToDom(objs, dom, parent, collectedHist)
3
4 if isempty(objs)
5
6 % Create empty param node with the attribute 'shape'
7 utils.xml.attachEmptyObjectNode(objs, dom, parent);
8
9 else
10 for oo = 1:numel(objs)
11 obj = objs(oo);
12
13 % Create object node
14 paramNode = dom.createElement('param');
15 paramNode.setAttribute('shape', sprintf('%dx%d', size(objs)));
16
17 % Call superclass
18 collectedHist = attachToDom@ltpda_nuo(obj, dom, paramNode, collectedHist);
19
20 % Add key
21 paramNode.setAttribute('key', obj.key);
22
23 % Add param value
24 val = obj.getVal;
25
26 valNode = dom.createElement('val');
27 valNode.setAttribute('shape', sprintf('%dx%d', size(val)));
28
29 if isnumeric(val) || islogical(val)
30 % We should have helper utilities for the types which are not objects.
31 % Again, we don't care here what happens inside the helper utility, it
32 % may add one or more nodes, or just write to attributes.
33
34 valNode.setAttribute('type', 'double');
35 utils.xml.attachNumberToDom(val, dom, valNode);
36 elseif ischar(val)
37 valNode.setAttribute('type', 'char');
38 utils.xml.attachCharToDom(val, dom, valNode);
39 elseif iscellstr(val)
40 content = dom.createTextNode(utils.xml.cellstr2str(val));
41 valNode.setAttribute('type', 'cellstr');
42 valNode.appendChild(content);
43 elseif iscell(val)
44 valNode.setAttribute('type', 'cell');
45 collectedHist = utils.xml.attachCellToDom(val, dom, valNode, collectedHist);
46 elseif isstruct(val)
47 valNode.setAttribute('type', 'struct');
48 collectedHist = utils.xml.attachStructToDom(val, dom, valNode, collectedHist);
49 elseif isa(val, 'sym')
50 valNode.setAttribute('type', 'sym');
51 utils.xml.attachSymToDom(val, dom, valNode);
52 elseif isa(val, 'history')
53 histUUIDs = val(1).UUID;
54 for hh = 2:numel(val)
55 histUUIDs = [histUUIDs, ' ', val(hh).UUID];
56 end
57 valNode.setAttribute('type', 'history');
58 valNode.setAttribute('val', histUUIDs);
59 collectedHist = val.attachToDom(dom, parent, collectedHist);
60 elseif isa(val, 'ltpda_obj')
61 valNode.setAttribute('type', class(val));
62 collectedHist = val.attachToDom(dom, valNode, collectedHist);
63 elseif isa(val, 'sun.util.calendar.ZoneInfo')
64 content = dom.createTextNode(char(val.getID));
65 valNode.setAttribute('type', class(val));
66 valNode.appendChild(content);
67 else
68 error('### Unknown data type to attach [%s]', class(val));
69 end
70 paramNode.appendChild(valNode);
71
72 % Add desc
73 paramNode.setAttribute('desc', obj.desc);
74
75 % Add the properties of the paramValue object to the param node
76 if isa(obj.val, 'paramValue')
77 prop = obj.val.property;
78 if ~isempty(prop)
79 paramPropertiesNode = dom.createElement('properties');
80 collectedHist = utils.xml.attachStructToDom(prop, dom, paramPropertiesNode, collectedHist);
81 paramNode.appendChild(paramPropertiesNode);
82 end
83 end
84
85 % Add to parent node
86 parent.appendChild(paramNode);
87
88 end
89 end
90
91 end