Subversion Repositories svn.mios

Rev

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

Rev Author Line No. Line
709 adamjking 1
package org.midibox.midi.xml;
2
 
721 adamjking 3
import java.util.Iterator;
709 adamjking 4
 
721 adamjking 5
import org.midibox.midi.MidiFilterDevice;
6
import org.midibox.midi.MidiFilterDeviceManager;
7
import org.midibox.utils.xml.XMLUtils;
8
import org.w3c.dom.Element;
9
import org.w3c.dom.Node;
10
 
11
public class MidiFilterDeviceManagerXML extends XMLUtils {
12
 
13
    protected MidiFilterDeviceManager midiFilterDeviceManager;
14
 
15
    protected String midiFilterDevicesTag = "midiFilterDevices";
16
 
17
    protected String midiFilterDeviceTag = "midiFilterDevice";
18
 
19
    public MidiFilterDeviceManagerXML(MidiFilterDeviceManager midiFilterDeviceManager, String rootElementTag) {
20
 
21
        super(rootElementTag);
22
 
23
        this.midiFilterDeviceManager = midiFilterDeviceManager;
24
 
25
        tags.add(midiFilterDevicesTag);
26
        tags.add(midiFilterDeviceTag);
27
    }
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
        } else if (name == midiFilterDevicesTag) {
39
 
40
        } else if (name == midiFilterDeviceTag) {
41
 
42
            MidiFilterDevice midiFilterDevice = midiFilterDeviceManager.addMidiFilterDevice();
43
 
44
            MidiFilterDeviceXML midiFilterDeviceXML = new MidiFilterDeviceXML(midiFilterDevice, midiFilterDeviceTag);
45
 
46
            midiFilterDeviceXML.loadXML(element);
47
        }
48
    }
49
 
50
    public void saveXML(Node node) {
51
 
52
        super.saveXML(node);
53
 
54
        Element midiFilterDevicesElement = document
55
                .createElement(midiFilterDevicesTag);
56
 
57
        rootElement.appendChild(midiFilterDevicesElement);
58
 
59
        Iterator it = midiFilterDeviceManager.getMidiFilterDevices().iterator();
60
 
61
        while (it.hasNext()) {
62
 
63
            MidiFilterDevice midiFilterDevice = (MidiFilterDevice) it.next();
64
 
65
            MidiFilterDeviceXML midiFilterDeviceXML = new MidiFilterDeviceXML(midiFilterDevice, midiFilterDeviceTag);
66
 
67
            midiFilterDeviceXML.saveXML(midiFilterDevicesElement);
68
        }
69
    }
709 adamjking 70
}