Ejemplo n.º 1
0
    public void body(String namespace, String name, String text) throws Exception {
      super.body(namespace, name, text);

      if (text != null) {
        ((XmlNodeData) this.treeNode.getData()).setText(text.trim());
      }
    }
Ejemplo n.º 2
0
    public void end(String namespace, String name) throws Exception {
      super.end(namespace, name);

      level--;

      if (idsList.size() - 1 > level + 1) {
        // idsList grew larger than we really need
        idsList.remove(idsList.size() - 1);
      }

      if (exclusionSets.size() - 1 > level + 1) {
        // the same condition as above
        exclusionSets.remove(exclusionSets.size() - 1);
      }

      this.treeNode = (TreeNode) this.treeNodesList.remove(this.treeNodesList.size() - 1);
    }
Ejemplo n.º 3
0
    public void begin(String namespace, String name, Attributes attributes) throws Exception {
      super.begin(namespace, name, attributes);

      level++;

      XmlNodeData xmlNodeData = new XmlNodeData();
      xmlNodeData.setName(name);
      xmlNodeData.setNamespace(namespace);

      String id = null;

      if (attributes != null) {
        int length = attributes.getLength();
        for (int i = 0; i < length; i++) {
          xmlNodeData.setAttribute(attributes.getQName(i), attributes.getValue(i));
        }

        id = attributes.getValue("id");
      }

      if (exclusionSets.size() == level) {
        exclusionSets.add(null);
      }

      if (id == null || id.length() == 0) {
        int currentId = 0;

        if (idsList.size() <= level) {
          for (int i = idsList.size(); i <= level; i++) {
            idsList.add(null);
          }
        } else {
          Integer integer = (Integer) idsList.get(level);
          currentId = integer.intValue() + 1;
        }

        Set exclusions = (Set) exclusionSets.get(level);

        while (exclusions != null && exclusions.contains(Integer.toString(currentId))) {
          currentId++;
        }

        idsList.set(level, new Integer(currentId));

        id = Integer.toString(currentId);
      } else {
        Set exclusions = (Set) exclusionSets.get(level);
        if (exclusions == null) {
          exclusions = new HashSet();

          exclusionSets.set(level, exclusions);
        }

        exclusions.add(id);
      }

      TreeNode node = new TreeNodeImpl();
      node.setData(xmlNodeData);

      this.treeNode.addChild(id, node);
      this.treeNodesList.add(this.treeNode);
      this.treeNode = node;
    }