Ignore:
Timestamp:
01/30/12 11:27:44 (12 years ago)
Author:
sherbold
Message:
  • the de.ugoe.cs.eventbench.jfc.JFCLogParser for the parsing of XML files generated from logs created by the JFCMonitor now can filter event types, e.g., to simplify recorded sequences (MOUSE_CLICKED instead of MOUSE_PRESSED, MOUSE_RELEASED, MOUSE_CLICKED)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/jfc/JFCLogParser.java

    r359 r369  
    11package de.ugoe.cs.eventbench.jfc; 
    22 
     3import java.awt.event.MouseEvent; 
    34import java.io.File; 
    45import java.io.FileInputStream; 
     
    910import java.security.InvalidParameterException; 
    1011import java.util.Collection; 
     12import java.util.HashSet; 
    1113import java.util.LinkedList; 
    1214import java.util.List; 
     
    5860         */ 
    5961        private List<JFCEvent> currentSequence = null; 
    60          
     62 
    6163        /** 
    6264         * <p> 
     
    8789        ParamSource paramSource = null; 
    8890 
     91        private Collection<Integer> eventFilter; 
     92 
    8993        /** 
    9094         * <p> 
     
    9599                sequences = new LinkedList<List<JFCEvent>>(); 
    96100                currentSequence = new LinkedList<JFCEvent>(); 
     101                setupEventFilter(); 
     102        } 
     103 
     104        private void setupEventFilter() { 
     105                eventFilter = new HashSet<Integer>(); 
     106                eventFilter.add(MouseEvent.MOUSE_PRESSED); 
     107                eventFilter.add(MouseEvent.MOUSE_RELEASED); 
    97108        } 
    98109 
     
    117128        public void startElement(String uri, String localName, String qName, 
    118129                        Attributes atts) throws SAXException { 
    119                 if( qName.equals("sessions") ) { 
     130                if (qName.equals("sessions")) { 
    120131                        currentSequence = new LinkedList<JFCEvent>(); 
    121132                } 
     
    127138                        currentSequence = new LinkedList<JFCEvent>(); 
    128139                } else if (qName.equals("event")) { 
    129                         currentEvent = new JFCEvent(atts.getValue("id")); 
    130                         paramSource = ParamSource.EVENT; 
    131                 } else if (qName.equals("param")) { 
    132                         if (paramSource == ParamSource.EVENT) { 
    133                                 currentEvent.addParameter(atts.getValue("name"), 
    134                                                 atts.getValue("value")); 
    135                         } else if (paramSource == ParamSource.SOURCE) { 
    136                                 currentEvent.addSourceInformation(atts.getValue("name"), 
    137                                                 atts.getValue("value")); 
    138                         } else if (paramSource == ParamSource.PARENT) { 
    139                                 currentEvent.addParentInformation(atts.getValue("name"), 
    140                                                 atts.getValue("value")); 
    141                         } else if (paramSource == ParamSource.COMPONENT) { 
    142                                 componentString += "'" + atts.getValue("value") + "',"; 
    143                         } 
    144                 } else if (qName.equals("source")) { 
    145                         paramSource = ParamSource.SOURCE; 
    146                 } else if (qName.equals("parent")) { 
    147                         paramSource = ParamSource.PARENT; 
    148                 } else if (qName.equals("component")) { 
    149                         paramSource = ParamSource.COMPONENT; 
    150                         componentString = "["; 
     140                        int eventId = Integer.parseInt(atts.getValue("id")); 
     141                        if (!eventFilter.contains(eventId)) { 
     142                                currentEvent = new JFCEvent(atts.getValue("id")); 
     143                                paramSource = ParamSource.EVENT; 
     144                        } 
     145                } else if (currentEvent != null) { 
     146                        if (qName.equals("param")) { 
     147                                if (paramSource == ParamSource.EVENT) { 
     148                                        currentEvent.addParameter(atts.getValue("name"), 
     149                                                        atts.getValue("value")); 
     150                                } else if (paramSource == ParamSource.SOURCE) { 
     151                                        currentEvent.addSourceInformation(atts.getValue("name"), 
     152                                                        atts.getValue("value")); 
     153                                } else if (paramSource == ParamSource.PARENT) { 
     154                                        currentEvent.addParentInformation(atts.getValue("name"), 
     155                                                        atts.getValue("value")); 
     156                                } else if (paramSource == ParamSource.COMPONENT) { 
     157                                        componentString += "'" + atts.getValue("value") + "',"; 
     158                                } 
     159                        } else if (qName.equals("source")) { 
     160                                paramSource = ParamSource.SOURCE; 
     161                        } else if (qName.equals("parent")) { 
     162                                paramSource = ParamSource.PARENT; 
     163                        } else if (qName.equals("component")) { 
     164                                paramSource = ParamSource.COMPONENT; 
     165                                componentString = "["; 
     166                        } 
    151167                } 
    152168        } 
     
    161177        public void endElement(String uri, String localName, String qName) 
    162178                        throws SAXException { 
    163                 if (qName.equals("event")) { 
    164                         currentSequence.add(currentEvent); 
    165                 } else if (qName.equals("source")) { 
    166                         paramSource = ParamSource.EVENT; 
    167                 } else if (qName.equals("parent")) { 
    168                         paramSource = ParamSource.SOURCE; 
    169                 } else if (qName.equals("sessions")) { 
    170                         if(currentSequence!=null && !currentSequence.isEmpty() ) { 
     179                if (qName.equals("sessions")) { 
     180                        if (currentSequence != null && !currentSequence.isEmpty()) { 
    171181                                sequences.add(currentSequence); 
    172182                        } 
    173183                        currentSequence = null; 
    174                 } else if (qName.equals("component")) { 
    175                         paramSource.equals(ParamSource.SOURCE); 
    176                         currentEvent.extendTarget(componentString.substring(0, componentString.length()-1)+"]"); 
     184                } else if (currentEvent != null) { 
     185                        if (qName.equals("event")) { 
     186                                currentSequence.add(currentEvent); 
     187                                currentEvent = null; 
     188                        } else if (qName.equals("source")) { 
     189                                paramSource = ParamSource.EVENT; 
     190                        } else if (qName.equals("parent")) { 
     191                                paramSource = ParamSource.SOURCE; 
     192                        } else if (qName.equals("component")) { 
     193                                paramSource.equals(ParamSource.SOURCE); 
     194                                currentEvent.extendTarget(componentString.substring(0, 
     195                                                componentString.length() - 1) + "]"); 
     196                        } 
    177197                } 
    178198        } 
Note: See TracChangeset for help on using the changeset viewer.