use of electric.xml.Element in project blue by kunstmusik.
the class Weibull method saveAsXML.
@Override
public Element saveAsXML() {
Element retVal = new Element("probabilityGenerator");
retVal.setAttribute("type", getClass().getName());
retVal.addElement(XMLUtilities.writeDouble("s", s));
retVal.addElement(XMLUtilities.writeDouble("t", t));
retVal.addElement(XMLUtilities.writeBoolean("sTableEnabled", sTableEnabled));
retVal.addElement(XMLUtilities.writeBoolean("tTableEnabled", tTableEnabled));
Element sTableNode = sTable.saveAsXML();
sTableNode.setAttribute("tableId", "sTable");
Element tTableNode = tTable.saveAsXML();
tTableNode.setAttribute("tableId", "tTable");
retVal.addElement(sTableNode);
retVal.addElement(tTableNode);
return retVal;
}
use of electric.xml.Element in project blue by kunstmusik.
the class Weibull method loadFromXML.
public static ProbabilityGenerator loadFromXML(Element data) {
Weibull retVal = new Weibull();
Elements nodes = data.getElements();
while (nodes.hasMoreElements()) {
Element node = nodes.next();
String nodeName = node.getName();
switch(nodeName) {
case "s":
retVal.s = XMLUtilities.readDouble(node);
break;
case "t":
retVal.t = XMLUtilities.readDouble(node);
break;
case "sTableEnabled":
retVal.sTableEnabled = XMLUtilities.readBoolean(node);
break;
case "tTableEnabled":
retVal.tTableEnabled = XMLUtilities.readBoolean(node);
break;
case "table":
String tableId = node.getAttributeValue("tableId");
switch(tableId) {
case "sTable":
retVal.sTable = Table.loadFromXML(node);
break;
case "tTable":
retVal.tTable = Table.loadFromXML(node);
break;
}
break;
}
}
return retVal;
}
use of electric.xml.Element in project blue by kunstmusik.
the class LiveObjectTest method testSerialization.
/**
* Test of getSoundObject method, of class blue.blueLive.LiveObject.
*/
public void testSerialization() {
LiveObject liveObj = new LiveObject();
liveObj.setSObj(new GenericScore());
Element elem1 = liveObj.saveAsXML(null);
Element elem2;
try {
elem2 = liveObj.loadFromXML(elem1, null).saveAsXML(null);
assertEquals(elem1.toString(), elem2.toString());
} catch (Exception ex) {
ex.printStackTrace();
fail("Did not load from xml");
}
}
use of electric.xml.Element in project blue by kunstmusik.
the class ProjectUpgrader_2_3_0 method upgradeTempo.
protected boolean upgradeTempo(Element data) {
Element element = data.getElement("soundObject");
Element tempoNode = data.getElement("tempo");
if (element == null && tempoNode == null) {
return false;
}
Element score = data.addElement("score");
if (element != null) {
Element elem = data.removeElement("soundObject");
TimeState timeState = TimeState.loadFromXML(elem);
score.addElement(timeState.saveAsXML());
score.addElement((Element) elem.clone());
}
if (tempoNode != null) {
Element elem = data.removeElement("tempo");
score.addElement((Element) elem.clone());
}
return true;
}
use of electric.xml.Element in project blue by kunstmusik.
the class JMask method loadFromXML.
public static SoundObject loadFromXML(Element data, Map<String, Object> objRefMap) throws Exception {
JMask jmask = new JMask();
SoundObjectUtilities.initBasicFromXML(data, jmask);
Elements nodes = data.getElements();
while (nodes.hasMoreElements()) {
Element node = nodes.next();
String nodeName = node.getName();
switch(nodeName) {
case "field":
jmask.setField(Field.loadFromXML(node));
break;
case "seed":
jmask.setSeed(Long.parseLong(node.getTextString()));
break;
case "seedUsed":
jmask.setSeedUsed(Boolean.parseBoolean(node.getTextString()));
break;
}
}
return jmask;
}
Aggregations