Exemplo n.º 1
0
  private String loadRule(Element rule, String id) throws DataConversionException {
    Rule dataRule = new Rule(allVars, id, id, rule.getAttribute("weight").getIntValue());
    java.util.List<?> elements = rule.getChildren();

    for (final Object element : elements) {
      Element child = (Element) element;
      String elementName = child.getName();

      if (elementName.equals("GETLIST")) {
        String listId = child.getAttributeValue("idref");
        dataRule.add(listId);
      } else if (elementName.equals("SPACE")) {
        SpaceRule sp = new SpaceRule();
        allVars.addDataElement(sp);
        dataRule.add(sp.getId());
      } else if (elementName.equals("HYPHEN")) {
        HyphenRule hy = new HyphenRule();
        allVars.addDataElement(hy);
        dataRule.add(hy.getId());
      } else if (elementName.equals("CR")) {
        CRRule cr = new CRRule();
        allVars.addDataElement(cr);
        dataRule.add(cr.getId());
      } else if (elementName.equals("GETRULE")) {
        String ruleId = child.getAttributeValue("idref");
        dataRule.add(ruleId);
      }
    }

    allVars.addDataElement(dataRule);

    return dataRule.getId();
  }
Exemplo n.º 2
0
  private String loadList(Element list) throws DataConversionException {
    pcgen.core.doomsdaybook.DDList dataList =
        new pcgen.core.doomsdaybook.DDList(
            allVars, list.getAttributeValue("title"), list.getAttributeValue("id"));
    java.util.List<?> elements = list.getChildren();

    for (final Object element : elements) {
      Element child = (Element) element;
      String elementName = child.getName();

      if (elementName.equals("VALUE")) {
        WeightedDataValue dv =
            new WeightedDataValue(child.getText(), child.getAttribute("weight").getIntValue());
        List<?> subElements = child.getChildren("SUBVALUE");

        for (final Object subElement1 : subElements) {
          Element subElement = (Element) subElement1;
          dv.addSubValue(subElement.getAttributeValue("type"), subElement.getText());
        }

        dataList.add(dv);
      }
    }

    allVars.addDataElement(dataList);

    return dataList.getId();
  }
Exemplo n.º 3
0
  private void loadFromDocument(Document nameSet) throws DataConversionException {
    Element generator = nameSet.getRootElement();
    java.util.List<?> rulesets = generator.getChildren("RULESET");
    java.util.List<?> lists = generator.getChildren("LIST");
    ListIterator<?> listIterator = lists.listIterator();

    // TODO This is a "dead local store" - is this intended to do something? thpr 10/21/06
    RuleSet rs = new RuleSet(allVars);

    while (listIterator.hasNext()) {
      Element list = (Element) listIterator.next();
      loadList(list);
    }

    for (final Object ruleset : rulesets) {
      Element ruleSet = (Element) ruleset;
      rs = loadRuleSet(ruleSet);
      allVars.addDataElement(rs);
    }
  }