Changeset 413 for trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/windows
- Timestamp:
- 04/03/12 10:51:34 (13 years ago)
- Location:
- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/windows
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/windows/commands/CMDparseXML.java
r297 r413 9 9 import de.ugoe.cs.eventbench.data.GlobalDataContainer; 10 10 import de.ugoe.cs.eventbench.windows.MFCLogParser; 11 import de.ugoe.cs.eventbench.windows.data.MFCTargetComparator; 11 12 import de.ugoe.cs.eventbench.windows.data.WindowTree; 12 13 import de.ugoe.cs.eventbench.windows.data.WindowsEvent; … … 63 64 64 65 Collection<List<WindowsEvent>> sequences = parser.getSequences(); 66 67 Console.traceln("Pre-computing event target equalities."); 68 // compare all Events to a dummy event to make sure they are known by 69 // the MFCTargetComparator 70 WindowsEvent dummyEvent = new WindowsEvent("dummy"); 71 for (List<WindowsEvent> sequence : sequences) { 72 for (WindowsEvent event : sequence) { 73 event.equals(dummyEvent); 74 } 75 } 76 MFCTargetComparator.setMutable(false); 77 65 78 SortedSet<String> targets = WindowTree.getInstance().getTargets(); 66 79 -
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/windows/data/WindowsEvent.java
r198 r413 1 1 package de.ugoe.cs.eventbench.windows.data; 2 3 import java.io.ByteArrayInputStream; 4 5 import javax.xml.parsers.DocumentBuilder; 6 import javax.xml.parsers.DocumentBuilderFactory; 7 8 import org.w3c.dom.Document; 9 import org.w3c.dom.Element; 10 import org.w3c.dom.NodeList; 2 11 3 12 import de.ugoe.cs.eventbench.data.ReplayableEvent; … … 33 42 } 34 43 44 @Override 45 protected boolean targetEquals(String otherTarget) { 46 return MFCTargetComparator.compare(target, otherTarget); 47 } 48 49 int targetHash = 0; 50 51 @Override 52 protected int targetHashCode() { 53 if( targetHash==0 ) { 54 int multiplier = 17; 55 if (target != null) { 56 Document doc; 57 try { 58 DocumentBuilder documentBuilder = DocumentBuilderFactory 59 .newInstance().newDocumentBuilder(); 60 doc = documentBuilder.parse(new ByteArrayInputStream( 61 ("<dummy>" + target + "</dummy>").getBytes("UTF-8"))); 62 } catch (Exception e) { 63 e.printStackTrace(); 64 return 0; 65 } 66 doc.getDocumentElement().normalize(); 67 NodeList widgets = doc.getElementsByTagName("window"); 68 69 for (int i = 0; i < widgets.getLength(); i++) { 70 Element currentWidget = (Element) widgets.item(i); 71 targetHash = targetHash* multiplier + widgetHashCode(currentWidget); 72 } 73 } 74 } 75 return targetHash; 76 } 77 78 private int widgetHashCode(Element currentWidget) { 79 int hashCode = 0; 80 int multiplier = 41; 81 hashCode = hashCode * multiplier + currentWidget.getAttribute("class").hashCode(); 82 hashCode = hashCode * multiplier + currentWidget.getAttribute("resourceId").hashCode(); 83 hashCode = hashCode * multiplier + currentWidget.getAttribute("isModal").hashCode(); 84 return hashCode; 85 } 35 86 }
Note: See TracChangeset
for help on using the changeset viewer.