public Element saveAsXML() { Element retVal = new Element("probabilityGenerator"); retVal.setAttribute("type", getClass().getName()); retVal.addElement(XMLUtilities.writeInt("direction", direction)); retVal.addElement(XMLUtilities.writeDouble("lambda", lambda)); retVal.addElement(XMLUtilities.writeBoolean("lambdaTableEnabled", lambdaTableEnabled)); retVal.addElement(lambdaTable.saveAsXML()); return retVal; }
@Override public Element saveAsXML() { Element retVal = new Element("generator"); retVal.setAttribute("type", getClass().getName()); retVal.addElement(XMLUtilities.writeInt("listType", getListType())); retVal.addElement(XMLUtilities.writeInt("index", index)); retVal.addElement(XMLUtilities.writeInt("direction", direction)); Element items = new Element("listItems"); for (Iterator it = listItems.iterator(); it.hasNext(); ) { Double item = (Double) it.next(); items.addElement("item").setText(item.toString()); } retVal.addElement(items); return retVal; }
public static ProbabilityGenerator loadFromXML(Element data) { Exponential retVal = new Exponential(); Elements nodes = data.getElements(); while (nodes.hasMoreElements()) { Element node = nodes.next(); String nodeName = node.getName(); if (nodeName.equals("direction")) { retVal.direction = XMLUtilities.readInt(node); } else if (nodeName.equals("lambda")) { retVal.lambda = XMLUtilities.readDouble(node); } else if (nodeName.equals("lambdaTableEnabled")) { retVal.lambdaTableEnabled = XMLUtilities.readBoolean(node); } else if (nodeName.equals("table")) { retVal.lambdaTable = Table.loadFromXML(node); } } return retVal; }