Esempio n. 1
0
  private static ArrayList<AllPath> readAllPossiblePathFile(String filenameAndPath) {
    ArrayList<AllPath> allPossiblePath = new ArrayList<AllPath>();
    try {
      BufferedReader input = new BufferedReader(new FileReader(filenameAndPath));
      String line = "";
      while ((line = input.readLine()) != null) {

        String[] str = line.split("::");
        String startVertex = str[0];
        String endVertex = str[1];
        AllPath allPath = new AllPath(startVertex, endVertex);
        while (true) {
          String attributeName = "";
          String attributeValue = "";
          String elementName = "";
          //	ArrayList<ElementAttribute> attributes=new ArrayList<ElementAttribute>();
          DOMElement domElement = new DOMElement();
          while (!(line = input.readLine())
              .equals(
                  "---------------------------------------------------------------------------")) {
            if (line.equals(
                "===========================================================================")) {
              allPossiblePath.add(allPath);
              break;
            }
            if (line.contains("tagName::")) {
              elementName = line.split("::")[1];
              domElement.setDOMElementName(elementName);
            } else {
              String[] attr = line.split("::");
              attributeName = attr[0];
              attributeValue = attr[1];
              //			ElementAttribute attribute=new ElementAttribute(attributeName, attributeValue);
              domElement.setAttributes(attributeName, attributeValue);
              //			attributes.add(attribute);
            }
          }

          if (line.equals(
              "===========================================================================")) {

            break;
          }
          //		DOMElement domElement=new DOMElement(elementName, attributes);
          allPath.pushToQueue(domElement);
        }
      }
      input.close();
    } catch (IOException e) {

      e.printStackTrace();
    }
    return allPossiblePath;
  }
Esempio n. 2
0
  public DomMuteHelper(String outputFolder) {
    String filenameAndPath =
        Helper.addFolderSlashIfNeeded(outputFolder) + "allPossiblePath" + ".txt";
    ArrayList<AllPath> allPath = readAllPossiblePathFile(filenameAndPath);
    for (int i = 0; i < allPath.size(); i++) {
      paths = allPath.get(0);
    }

    domTraceReading = new DomTraceReading(outputFolder);
    Queue<DOMElement> eventSequence = paths.getEventSequence();

    for (DOMElement event : eventSequence) {
      HashMap<String, String> events = event.getElementAttributes();
      Set<String> keys = events.keySet();
      Iterator<String> iter = keys.iterator();
      while (iter.hasNext()) {
        String attrName = iter.next();
        String attrValue = events.get(attrName);
        if (attrName.equals("xpath")) {
          excludedElementsList.add(attrValue);
        }
      }
    }
  }