Exemplo n.º 1
0
  private int getNodeCnt(BioFuzzParseNode node) {
    if (node == null) return 0;

    int s = 1;

    List<BioFuzzParseNode> children = null;

    if (node.hasChildren() && (children = node.getChildren()) != null) {
      Iterator<BioFuzzParseNode> iter = children.iterator();

      while (iter.hasNext()) {
        s += getNodeCnt(iter.next());
      }
    }
    return s;
  }
Exemplo n.º 2
0
  private BioFuzzParseNode getNodeByIdx(BioFuzzParseNode node, int tokIdx) {

    if (node.getTokIdx() == tokIdx) {
      return node;
    }

    List<BioFuzzParseNode> children = null;

    if ((children = node.getChildren()) != null && node.hasChildren()) {
      Iterator<BioFuzzParseNode> iter = children.iterator();
      while (iter.hasNext()) {
        BioFuzzParseNode ret = getNodeByIdx(iter.next(), tokIdx);
        if (ret != null) return ret;
      }
    }

    return null;
  }
Exemplo n.º 3
0
  private String genStr(BioFuzzParseNode node, int level) {
    String s = "";

    List<BioFuzzParseNode> children = null;

    // if ((children = node.getChildren()) != null) {
    if (node.hasChildren()) {
      children = node.getChildren();
      assert (children != null);
      Iterator<BioFuzzParseNode> iter = children.iterator();

      while (iter.hasNext()) {
        BioFuzzParseNode child = iter.next();
        s += StringUtils.repeat(" ", level) + "|--" + child.toString();
        s +=
            "[AttackTag: "
                + child.getAtagName()
                + "("
                + child.getAtagType().toString()
                + ")"
                + "("
                + child.getVal()
                + ")]\n"
                + genStr(child, level + 1);
      }
    } else {
      if (this.tokLst != null) {
        s += StringUtils.repeat(" ", level) + "|--" + node.toString();

        s +=
            "[Tok: "
                + this.tokLst.get(node.getTokIdx())
                + "("
                + node.getAtagType().toString()
                + ")"
                + "("
                + node.getVal()
                + ")]\n";
      }
    }
    // }
    return s;
  }
Exemplo n.º 4
0
  private BioFuzzParseNode getNodeById(BioFuzzParseNode node, int id) {

    BioFuzzParseNode res = null;

    if (node == null) return res;

    // logger.debug("node id: " + node.getId() + "id " + id);

    if (node.getId() == id) {
      // logger.debug("here");
      res = node;
    }

    if (node.hasChildren() && res == null) {
      for (BioFuzzParseNode child : node.getChildren()) {
        if ((res = getNodeById(child, id)) != null) {
          break;
        }
      }
    }

    return res;
  }