Example #1
0
  private static XMLReader getParser(TPENode root, ResultsCollector r) throws SAXException {
    if (!root.isRootNode()) {
      throw new RuntimeException("Provided root node is not a root node!");
    }

    XMLReader parser = XMLReaderFactory.createXMLReader();
    ContentHandler contentHandler = new StackEval(root, r);
    parser.setContentHandler(contentHandler);

    return parser;
  }
  /**
   * Creates a holder for all results: for each in the solution space, we create a placeholder,
   * which can be filled in later by other queryes.
   *
   * <p>precondition: results.size > 0
   *
   * @return
   */
  protected static HashMap<TPENode, Match> buildEmptyResultMatch(TPENode rootnode) {
    ArrayList<TPENode> nodes = TPENode.getDescendents(rootnode);

    // build the tree of nodes and set their default values with null,
    // the real values will be set later if possible.
    HashMap<TPENode, Match> resultsmap = new HashMap<TPENode, Match>();
    for (TPENode node : nodes) {
      if (node.resultvalue == true) {
        resultsmap.put(node, null);
      }
    }

    return resultsmap;
  }