Exemplo n.º 1
0
  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;
  }
Exemplo n.º 2
0
  @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;
  }
Exemplo n.º 3
0
  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;
  }