Example #1
0
  public Node findChild(String uid) {
    for (Node current : children) {
      if (current.getId().equals(uid)) {
        return current;
      }
    }

    return null;
  }
Example #2
0
  public void printUI() {
    boolean hasChildren = false;
    if (children.size() > 0) hasChildren = true;
    StringBuffer sb = new StringBuffer(LENGTH);
    // get the current level of the node so that we can do pretty print
    int level = this.getLevel();
    for (int i = 0; i < level; i++) {
      sb.append("  ");
    }
    sb.append(Ui.getType(attributes.get(TAG), attributes, hasChildren))
        .append("(UID: '")
        .append(id)
        .append("', clocator: [");
    if (attributes.size() == 0) {
      sb.append(":");
    } else {
      int count = 0;
      for (String key : attributes.keySet()) {
        if (++count > 1) sb.append(",");
        sb.append(key).append(":").append("'").append(attributes.get(key)).append("'");
      }
    }

    sb.append("]");
    // comment this line out if you do not want xpath to display
    sb.append("[xpath: ").append(xpath).append("]");
    sb.append(")");
    if (hasChildren) sb.append("{");
    System.out.println(sb.toString());
    if (hasChildren) {
      for (Node node : children) {
        node.printUI();
      }
    }
    if (hasChildren) {
      StringBuffer indent = new StringBuffer(LENGTH);
      for (int i = 0; i < level; i++) {
        indent.append("  ");
      }
      indent.append("}");
      System.out.println(indent.toString());
    }
  }