Ejemplo n.º 1
0
  @Override
  public SimulationSpec makeObject(Element e) throws LoadFailedException {
    cycleCheck();
    String replacement = getAttributeNS(e, SPEC, "src");
    if (replacement != null)
      return loadRelative(replacement, SimulationSpec.class, new SimulationSpecXMLLoader(this));
    executeUndecorators(ss, e);

    Signature s =
        loadSub(
            selectFirst(
                getNamedChildElement(e, SIGNATURE, "signature"),
                getNamedChildElement(e, SPEC, "signature")),
            SPEC,
            Signature.class,
            new SignatureXMLLoader(this));
    if (s != null)
      addChange(
          new SimulationSpec.ChangeSetSignatureDescriptor(
              new SimulationSpec.Identifier(), null, s));

    int index = 0;
    for (Element n : forNodeList(e.getChildNodes()).filter(Element.class)) {
      String ns = n.getNamespaceURI();
      if ((SPEC.equals(ns) || RULE.equals(ns)) && "rule".equals(n.getLocalName())) {
        ReactionRule rr = loadSub(n, SPEC, ReactionRule.class, new ReactionRuleXMLLoader(this));
        if (rr != null)
          addChange(
              new SimulationSpec.ChangeAddRuleDescriptor(
                  new SimulationSpec.Identifier(), index++, rr));
      }
    }

    Bigraph b =
        loadSub(
            selectFirst(
                getNamedChildElement(e, BIGRAPH, "bigraph"),
                getNamedChildElement(e, SPEC, "model")),
            SPEC,
            Bigraph.class,
            new BigraphXMLLoader(this));
    if (b != null)
      addChange(
          new SimulationSpec.ChangeSetModelDescriptor(new SimulationSpec.Identifier(), null, b));

    executeChanges();
    return ss;
  }