Subversion Repositories svn.mios

Rev

Rev 800 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 800 Rev 850
Line 1... Line 1...
1
package org.midibox.midi.xml;
1
package org.midibox.midi.xml;
-
 
2
-
 
3
import java.io.File;
2
4
3
import org.midibox.midi.SysexSendReceive;
5
import org.midibox.midi.SysexSendReceive;
4
import org.midibox.utils.xml.XMLUtils;
6
import org.midibox.utils.xml.XMLUtils;
-
 
7
import org.w3c.dom.Element;
5
import org.w3c.dom.Node;
8
import org.w3c.dom.Node;
6
9
7
public class SysexSendReceiveXML extends XMLUtils {
10
public class SysexSendReceiveXML extends XMLUtils {
8
11
9
    public final static String TAG_ROOT_ELEMENT = "sysexSendReceive";
12
    public final static String TAG_ROOT_ELEMENT = "sysexSendReceive";
-
 
13
-
 
14
    public final static String TAG_SEND_FILE = "sendSysexFile";
-
 
15
-
 
16
    public final static String ATTR_SEND_DELAY_TIME = "sendDelayTime";
10
17
11
    protected SysexSendReceive sysexSendReceive;
18
    protected SysexSendReceive sysexSendReceive;
12
19
13
    public SysexSendReceiveXML(SysexSendReceive sysexSendReceive,
20
    public SysexSendReceiveXML(SysexSendReceive sysexSendReceive,
14
            String rootElementTag) {
21
            String rootElementTag) {
15
22
16
        super(rootElementTag);
23
        super(rootElementTag);
17
24
18
        this.sysexSendReceive = sysexSendReceive;
25
        this.sysexSendReceive = sysexSendReceive;
-
 
26
-
 
27
        addTag(TAG_SEND_FILE);
-
 
28
    }
-
 
29
-
 
30
    protected void parseElement(Element element) {
-
 
31
-
 
32
        super.parseElement(element);
-
 
33
-
 
34
        String name = element.getNodeName();
-
 
35
-
 
36
        if (name == rootElementTag) {
-
 
37
-
 
38
            if (element.getAttribute(ATTR_SEND_DELAY_TIME) != "") {
-
 
39
-
 
40
                sysexSendReceive.setSendDelayTime(stringToInt(element
-
 
41
                        .getAttribute(ATTR_SEND_DELAY_TIME)));
-
 
42
            }
-
 
43
        }
-
 
44
-
 
45
        if (name == TAG_SEND_FILE) {
-
 
46
-
 
47
            File file = new File(element.getTextContent());
-
 
48
-
 
49
            if (file.exists()) {
-
 
50
-
 
51
                sysexSendReceive.setSendFile(file);
-
 
52
            }
-
 
53
        }
19
    }
54
    }
20
55
21
    public void saveXML(Node node) {
56
    public void saveXML(Node node) {
22
57
23
        super.saveXML(node);
58
        super.saveXML(node);
-
 
59
-
 
60
        rootElement.setAttribute(ATTR_SEND_DELAY_TIME,
-
 
61
                intToString(sysexSendReceive.getSendDelayTime()));
-
 
62
-
 
63
        File file = sysexSendReceive.getSendFile();
-
 
64
-
 
65
        if (file != null) {
-
 
66
-
 
67
            Element fileElement = document.createElement(TAG_SEND_FILE);
-
 
68
-
 
69
            rootElement.appendChild(fileElement);
-
 
70
-
 
71
            fileElement.setTextContent(file.getAbsolutePath());
-
 
72
        }
24
    }
73
    }
25
}
74
}