Exemplo n.º 1
0
  /**
   * Save the rule scheme.
   *
   * @param h AGG XML helper
   */
  public void XwriteObject(XMLHelper h) {
    h.openNewElem("RuleScheme", this);
    h.addAttr("name", this.schemeName);
    if (!this.enabled) h.addAttr("enabled", "false");

    h.addAttr("disjointMultis", String.valueOf(this.disjointMultis));
    h.addAttr("parallelKernel", String.valueOf(this.parallelKernel));
    h.addAttr("checkConflict", String.valueOf(this.checkDeleteUseConflict));
    h.addAttr("atLeastOneMultiMatch", String.valueOf(this.atLeastOneMultiMatch));
    h.addAttr("index", this.itsIndex);

    h.openSubTag("Kernel");
    h.addObject("", this.kernelRule, true);
    h.close();

    for (int i = 0; i < this.multiRules.size(); i++) {
      h.openSubTag("Multi");
      final MultiRule r = (MultiRule) this.multiRules.get(i);
      h.addObject("", r, true);

      h.openSubTag("EmbeddingLeft");
      r.getEmbeddingLeft().writeMorphism(h);
      h.close();

      h.openSubTag("EmbeddingRight");
      r.getEmbeddingRight().writeMorphism(h);
      h.close();

      h.close();
    }

    if (this.amalgamRule != null) {
      h.openSubTag("Amalgamated");
      h.addObject("", this.amalgamRule, true);
      h.close();

      //			if (this.amalgamRule.getMatch() != null) {
      //				this.amalgamRule.getMatch().setName("MatchOf_" + this.amalgamRule.getName());
      //				h.openSubTag("MatchOf");
      //				h.addObject("Rule", this.amalgamRule, false);
      //				h.addObject("", this.amalgamRule.getMatch(), true);
      //				h.close();
      //			}
    }

    // TaggedValue layer
    h.openSubTag("TaggedValue");
    h.addAttr("Tag", "layer");
    h.addAttr("TagValue", this.layer);
    h.close();

    // TaggedValue priority
    h.openSubTag("TaggedValue");
    h.addAttr("Tag", "priority");
    h.addAttr("TagValue", this.priority);
    h.close();

    h.close();
  }
  /**
   * Writes the contents of this object to a file in a xml format.
   *
   * @param h A helper object for storing.
   */
  public void XwriteObject(XMLHelper h) {
    h.openNewElem("CriticalPairs", this);
    h.addObject("GraGra", getGrammar(), true);
    h.openSubTag("dependenciesContainer");

    String kind = "trigger_dependency";
    if (this.switchDependency) kind = "trigger_switch_dependency";
    h.addAttr("kind", kind);

    // Inhalt von excludeContainer schreiben (save)
    for (Enumeration<Rule> keys = this.excludeContainer.keys(); keys.hasMoreElements(); ) {
      Rule r1 = keys.nextElement();
      h.openSubTag("Rule");
      h.addObject("R1", r1, false);

      Hashtable<
              Rule,
              Pair<
                  Boolean,
                  Vector<
                      Pair<
                          Pair<OrdinaryMorphism, OrdinaryMorphism>,
                          Pair<OrdinaryMorphism, OrdinaryMorphism>>>>>
          secondPart = this.excludeContainer.get(r1);
      for (Enumeration<Rule> k2 = secondPart.keys(); k2.hasMoreElements(); ) {
        Rule r2 = k2.nextElement();
        h.openSubTag("Rule");
        h.addObject("R2", r2, false);
        Pair<
                Boolean,
                Vector<
                    Pair<
                        Pair<OrdinaryMorphism, OrdinaryMorphism>,
                        Pair<OrdinaryMorphism, OrdinaryMorphism>>>>
            p = secondPart.get(r2);
        Boolean b = p.first;
        h.addAttr("bool", b.toString());
        if (b.booleanValue()) {
          Vector<
                  Pair<
                      Pair<OrdinaryMorphism, OrdinaryMorphism>,
                      Pair<OrdinaryMorphism, OrdinaryMorphism>>>
              v = p.second;
          for (int i = 0; i < v.size(); i++) {
            Pair<Pair<OrdinaryMorphism, OrdinaryMorphism>, Pair<OrdinaryMorphism, OrdinaryMorphism>>
                p2i = v.elementAt(i);
            Pair<OrdinaryMorphism, OrdinaryMorphism> p2 = p2i.first;
            h.openSubTag("Overlapping_Pair");
            OrdinaryMorphism first = p2.first;
            Graph overlapping = first.getImage();
            /*
             * durch das true macht der String am Anfang keinen Sinn
             */
            h.addObject("", overlapping, true);

            Iterator<?> e = overlapping.getNodesSet().iterator();
            while (e.hasNext()) {
              GraphObject o = (GraphObject) e.next();
              if (o.isCritical()) {
                h.openSubTag("Critical");
                h.addObject("object", o, false);
                h.close();
              }
            }
            e = overlapping.getArcsSet().iterator();
            while (e.hasNext()) {
              GraphObject o = (GraphObject) e.next();
              if (o.isCritical()) {
                h.openSubTag("Critical");
                h.addObject("object", o, false);
                h.close();
              }
            }

            /*
             * first.writeMorphism(h);
             * ((OrdinaryMorphism)p2.second).writeMorphism(h);
             */

            writeOverlapMorphisms(h, r1, r2, p2i);

            h.close();
          }
        }
        h.close();
      }

      h.close();
    }
    h.close();
    h.openSubTag("conflictFreeContainer");
    for (Enumeration<Rule> keys = this.excludeContainer.keys(); keys.hasMoreElements(); ) {
      Rule r1 = keys.nextElement();
      h.openSubTag("Rule");
      h.addObject("R1", r1, false);

      Hashtable<
              Rule,
              Pair<
                  Boolean,
                  Vector<
                      Pair<
                          Pair<OrdinaryMorphism, OrdinaryMorphism>,
                          Pair<OrdinaryMorphism, OrdinaryMorphism>>>>>
          secondPart = this.conflictFreeContainer.get(r1);
      for (Enumeration<Rule> k2 = secondPart.keys(); k2.hasMoreElements(); ) {
        Rule r2 = k2.nextElement();
        h.openSubTag("Rule");
        h.addObject("R2", r2, false);
        Boolean b = secondPart.get(r2).first;
        h.addAttr("bool", b.toString());
        h.close();
      }

      h.close();
    }
    h.close();
    h.close();
  }