Example #1
0
 public XMLFight(Fight fight) {
   doc = XmlHelper.createDocument(null);
   this.fight = fight;
 }
Example #2
0
  public void parseXML(Node rootNode) {
    try {
      NumberFormat nf = WLPNumberFormat.getInstance();
      NamedNodeMap attrs = rootNode.getAttributes();
      if (attrs != null) {
        Node nameNode = attrs.getNamedItem(nameTag);
        if (nameNode != null) {
          name = nameNode.getTextContent().trim();
        }
        Node guidNode = attrs.getNamedItem(guidTag);
        if (guidNode != null) {
          guid = guidNode.getTextContent().trim();
        }
      }

      Node mergedNode = XmlHelper.getChildNode(rootNode, mergedTag);
      if (mergedNode != null) {
        merged = Boolean.parseBoolean(mergedNode.getTextContent().trim());
      }

      Node durationNode = XmlHelper.getChildNode(rootNode, durationTag);
      if (durationNode != null) {
        duration = nf.parse(durationNode.getTextContent().trim()).doubleValue();
      }

      Node activeDurationNode = XmlHelper.getChildNode(rootNode, activeDurationTag);
      if (activeDurationNode != null) {
        activeDuration = nf.parse(activeDurationNode.getTextContent().trim()).doubleValue();
      }

      Node numMobsNode = XmlHelper.getChildNode(rootNode, numMobsTag);
      if (numMobsNode != null) {
        numMobs = Integer.parseInt(numMobsNode.getTextContent().trim());
      }

      Node totalDamageNode = XmlHelper.getChildNode(rootNode, totalDamageTag);
      if (totalDamageNode != null) {
        totalDamage = Long.parseLong(totalDamageNode.getTextContent().trim());
      }

      Node victimNode = XmlHelper.getChildNode(rootNode, victimTag);
      if (victimNode != null) {
        Node victimFightparticipantNode =
            XmlHelper.getChildNode(victimNode, XMLFightParticipant.fightParticipantTag);
        if (victimFightparticipantNode != null) {
          xmlVictim = new XMLFightParticipant();
          xmlVictim.parseXML(victimFightparticipantNode);
        }
      }
      List<Node> fightParticipantNodes =
          XmlHelper.getChildNodes(rootNode, XMLFightParticipant.fightParticipantTag);
      fightParticipants = new ArrayList<XMLFightParticipant>();
      for (Node partNode : fightParticipantNodes) {
        if (partNode != null) {
          XMLFightParticipant xmlPart = new XMLFightParticipant();
          xmlPart.parseXML(partNode);
          fightParticipants.add(xmlPart);
        }
      }
    } catch (ParseException ex) {
      throw new NumberFormatException();
    }
  }