Subversion Repositories svn.mios

Rev

Rev 722 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
709 adamjking 1
package org.midibox.mios.xml;
2
 
721 adamjking 3
import org.midibox.mios.DebugFunctionParameters;
4
import org.midibox.utils.xml.XMLUtils;
727 adamjking 5
import org.w3c.dom.Element;
721 adamjking 6
import org.w3c.dom.Node;
709 adamjking 7
 
721 adamjking 8
public class DebugFunctionParametersXML extends XMLUtils {
9
 
722 adamjking 10
    protected final static String TAG_ROOT_ELEMENT = "debugFunctionParameters";
11
 
12
    protected final static String ATTR_ADDRESS = "address";
13
 
14
    protected final static String ATTR_WREG = "wreg";
15
 
16
    protected final static String ATTR_PARAM_1 = "param1";
17
 
18
    protected final static String ATTR_PARAM_2 = "param2";
19
 
20
    protected final static String ATTR_PARAM_3 = "param3";
21
 
721 adamjking 22
    protected DebugFunctionParameters debugFunctionParameters;
23
 
24
    public DebugFunctionParametersXML(
25
            DebugFunctionParameters debugFunctionParameters,
26
            String rootElementTag) {
27
 
28
        super(rootElementTag);
29
 
30
        this.debugFunctionParameters = debugFunctionParameters;
31
    }
32
 
727 adamjking 33
    protected void parseElement(Element element) {
34
 
35
        super.parseElement(element);
36
 
37
        String name = element.getNodeName();
38
 
39
        if (name == rootElementTag) {
40
 
41
            debugFunctionParameters.setAddress(stringToInt(element
42
                    .getAttribute(ATTR_ADDRESS)));
43
 
44
            debugFunctionParameters.setWreg(stringToInt(element
45
                    .getAttribute(ATTR_WREG)));
46
 
47
            debugFunctionParameters.setParam1(stringToInt(element
48
                    .getAttribute(ATTR_PARAM_1)));
49
 
50
            debugFunctionParameters.setParam2(stringToInt(element
51
                    .getAttribute(ATTR_PARAM_2)));
52
 
53
            debugFunctionParameters.setParam3(stringToInt(element
54
                    .getAttribute(ATTR_PARAM_3)));
55
        }
56
    }
57
 
721 adamjking 58
    public void saveXML(Node node) {
59
 
60
        super.saveXML(node);
61
 
722 adamjking 62
        rootElement.setAttribute(ATTR_ADDRESS,
63
                intToString(debugFunctionParameters.getAddress()));
721 adamjking 64
 
722 adamjking 65
        rootElement.setAttribute(ATTR_WREG, intToString(debugFunctionParameters
66
                .getWreg()));
721 adamjking 67
 
722 adamjking 68
        rootElement.setAttribute(ATTR_PARAM_1,
69
                intToString(debugFunctionParameters.getParam1()));
721 adamjking 70
 
722 adamjking 71
        rootElement.setAttribute(ATTR_PARAM_2,
72
                intToString(debugFunctionParameters.getParam2()));
721 adamjking 73
 
722 adamjking 74
        rootElement.setAttribute(ATTR_PARAM_3,
75
                intToString(debugFunctionParameters.getParam3()));
721 adamjking 76
    }
709 adamjking 77
}