Changeset 1232 for trunk/autoquest-plugin-html/src
- Timestamp:
- 06/27/13 09:16:35 (11 years ago)
- Location:
- trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/AbstractDefaultLogParser.java
r1093 r1232 33 33 import org.xml.sax.Attributes; 34 34 import org.xml.sax.InputSource; 35 import org.xml.sax.Locator; 35 36 import org.xml.sax.SAXException; 36 37 import org.xml.sax.SAXParseException; … … 116 117 /** 117 118 * <p> 119 * the handle to the locator for correctly throwing exceptions with location information 120 * </p> 121 */ 122 private Locator locator; 123 124 /** 125 * <p> 118 126 * Constructor. Creates a new logParser. 119 127 * </p> … … 134 142 * @param filename 135 143 * name and path of the log file 136 */ 137 public void parseFile(String filename) { 144 * 145 * @throws SAXException in the case, the file could not be parsed 146 */ 147 public void parseFile(String filename) throws SAXException { 138 148 if (filename == null) { 139 149 throw new IllegalArgumentException("filename must not be null"); … … 150 160 * @param file 151 161 * file to be parsed 152 */ 153 public void parseFile(File file) { 162 * 163 * @throws SAXException in the case, the file could not be parsed 164 */ 165 public void parseFile(File file) throws SAXException { 154 166 if (file == null) { 155 167 throw new IllegalArgumentException("file must not be null"); … … 167 179 Console.printerrln("Error parsing file " + file.getName()); 168 180 Console.logException(e); 169 return;181 throw new SAXParseException("Error parsing file " + file.getName(), locator, e); 170 182 } 171 183 catch (ParserConfigurationException e) { 172 184 Console.printerrln("Error parsing file " + file.getName()); 173 185 Console.logException(e); 174 return; 175 } 176 catch (SAXException e) { 177 Console.printerrln("Error parsing file " + file.getName()); 178 Console.logException(e); 186 throw new SAXParseException("Error parsing file " + file.getName(), locator, e); 179 187 } 180 188 catch (FileNotFoundException e) { 181 189 Console.printerrln("Error parsing file " + file.getName()); 182 190 Console.logException(e); 183 } 191 throw new SAXParseException("Error parsing file " + file.getName(), locator, e); 192 } 193 184 194 if (inputSource != null) { 185 195 inputSource.setSystemId("file://" + file.getAbsolutePath()); … … 190 200 saxParser.parse(inputSource, this); 191 201 } 192 catch (SAXParseException e) {193 Console.printerrln("Failure parsing file in line " + e.getLineNumber() +194 ", column " + e.getColumnNumber() + ".");195 Console.logException(e);196 }197 catch (SAXException e) {198 Console.printerrln("Error parsing file " + file.getName());199 Console.logException(e);200 return;201 }202 202 catch (IOException e) { 203 203 Console.printerrln("Error parsing file " + file.getName()); 204 204 Console.logException(e); 205 return;205 throw new SAXParseException("Error parsing file " + file.getName(), locator, e); 206 206 } 207 207 } … … 228 228 public GUIModel getGuiModel() { 229 229 return guiElementTree.getGUIModel(); 230 } 231 232 /* (non-Javadoc) 233 * @see org.xml.sax.helpers.DefaultHandler#setDocumentLocator(org.xml.sax.Locator) 234 */ 235 @Override 236 public void setDocumentLocator(Locator locator) { 237 this.locator = locator; 230 238 } 231 239 … … 298 306 /** 299 307 * <p> 300 * TODO: comment 301 * </p> 302 * 303 * @param id 304 * @param parameters 305 * @return 308 * called to handle parsed GUI elements 309 * </p> 310 * 311 * @param id the id of the parsed GUI element 312 * @param parameters all parameters parsed for the GUI element 313 * 314 * @return true, if the GUI element could be handled. In this case this method is not called 315 * again for the same GUI element. Otherwise the method is called later again. This 316 * may be required, if a child GUI element is parsed before the parent GUI element 306 317 */ 307 318 protected abstract boolean handleGUIElement(String id, Map<String, String> parameters) … … 310 321 /** 311 322 * <p> 312 * TODO: comment 313 * </p> 314 * 315 * @param id 316 * @param parameters 317 * @return 323 * called to handle parsed events 324 * </p> 325 * 326 * @param type the type of the parsed event 327 * @param parameters the parameters of the parsed event 328 * 329 * @return true, if the event could be handled. In this case this method is not called 330 * again for the same event. Otherwise the method is called later again. This 331 * may be required, if e.g. the target of the event, i.e. the GUI element, is not yet 332 * parsed 318 333 */ 319 334 protected abstract boolean handleEvent(String type, Map<String, String> parameters) … … 322 337 /** 323 338 * <p> 324 * TODO: comment325 * </p> 326 * 327 * @return 339 * returns the tree of parsed GUI elements, which consists of the ids of the GUI elements 340 * </p> 341 * 342 * @return as described 328 343 */ 329 344 protected GUIElementTree<String> getGUIElementTree() { … … 333 348 /** 334 349 * <p> 335 * TODO: comment350 * adds an event to the currently parsed sequence of events 336 351 * </p> 337 352 * … … 344 359 /** 345 360 * <p> 346 * TODO: comment 347 * </p> 348 * 361 * this method internally processes GUI elements, that have been parsed but not processed yet. 362 * I.e., for such GUI elements, either the method {@link #handleGUIElement(String, Map)} has 363 * not been called yet, or it returned false for the previous calls. In this case, the method 364 * is called (again). Furthermore, the processing of events is initiated by a call to 365 * {@link #processEvents()}. 366 * </p> 349 367 */ 350 368 private void processGUIElements() throws SAXException { … … 374 392 /** 375 393 * <p> 376 * TODO: comment 377 * </p> 378 * 394 * this method internally processes events, that have been parsed but not processed yet. 395 * I.e., for such events, either the method {@link #handleEvent(String, Map)} has 396 * not been called yet, or it returned false for the previous calls. In this case, the method 397 * is called (again). 398 * </p> 379 399 */ 380 400 private void processEvents() throws SAXException { … … 410 430 /** 411 431 * <p> 412 * T ODO document432 * This class is used internally for storing events and GUI elements in lists. 413 433 * </p> 414 434 */ -
trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/HTMLLogCompressor.java
r1230 r1232 35 35 /** 36 36 * <p> 37 * TODO comment 37 * This class can be used to compress a bunch of HTML log files to one file, that contains only 38 * one full GUI model. 38 39 * </p> 39 40 * 40 * @author Fabian Glaser,Patrick Harms41 * @author Patrick Harms 41 42 * @version 1.0 42 43 * … … 45 46 46 47 /** 47 * 48 * <p> 49 * The output writer into which the compressed variant of the log files is written 50 * </p> 48 51 */ 49 52 private PrintWriter outputWriter; 50 53 51 54 /** 55 * <p> 52 56 * the GUI elements, that were already logged and need therefore not be logged again into 53 57 * the same file 58 * </p> 54 59 */ 55 60 private Set<String> loggedGUIElementIds = new HashSet<String>(); 56 61 57 62 /** 63 * <p> 58 64 * the events that were read 65 * </p> 59 66 */ 60 67 private List<EventEntry> sortedEvents = new LinkedList<EventEntry>(); 61 68 62 69 /** 70 * <p> 71 * called to compress all log files in the provided directory. The method reuses 72 * {@link #compressFilesInDirectory(File)}. 73 * </p> 63 74 * 75 * @param directory the directory containing the log files to be compressed 64 76 */ 65 77 public void compressFilesInDirectory(String directory) { … … 72 84 73 85 /** 86 * <p> 87 * called to compress all log files in the provided directory. The directory if processed 88 * recursively. For each directory containing at least one log file the log files are 89 * replaced by one large log file containing the GUI model as well as all events contained in 90 * the compressed log file. If one log file could not be parsed, it is ignored and not 91 * compressed with the other ones. 92 * </p> 74 93 * 94 * @param directory the directory containing the log files to be compressed 75 95 */ 76 96 public void compressFilesInDirectory(File directory) { … … 213 233 214 234 /* (non-Javadoc) 215 * @see de.ugoe.cs.autoquest.plugin.html.AbstractDefaultLogParser#handleEvent( java.lang.String, java.util.Map)235 * @see de.ugoe.cs.autoquest.plugin.html.AbstractDefaultLogParser#handleEvent(String,Map) 216 236 */ 217 237 @Override … … 299 319 300 320 /** 301 * 321 * <p> 322 * this class is used internally for storing events in a sorted list together with the 323 * timestamps, being the sort criteria. 324 * </p> 302 325 */ 303 326 private class EventEntry { 304 327 305 328 /** 306 * 329 * <p> 330 * the type of the event 331 * </p> 307 332 */ 308 333 private String type; 309 334 310 335 /** 311 * 336 * <p> 337 * the parameters of the event 338 * </p> 312 339 */ 313 340 private Map<String, String> parameters; 314 341 315 342 /** 316 * 343 * <p> 344 * the timestamp of the event 345 * </p> 317 346 */ 318 347 private long timestamp; … … 320 349 /** 321 350 * <p> 322 * TODO: comment 323 * </p> 324 * 325 * @param type 326 * @param parameters 327 * @param timestamp 351 * creates a new event entry with event type, parameters and the timestamp 352 * </p> 328 353 */ 329 354 private EventEntry(String type, Map<String, String> parameters, long timestamp) { … … 334 359 335 360 /** 336 * 361 * <p> 362 * convenience method for dumping the event into the compressed log file 363 * </p> 337 364 */ 338 365 private void dump() { -
trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/HTMLLogParser.java
r1093 r1232 47 47 48 48 /** 49 * 49 * <p> 50 * the pattern used for parsing HTML GUI element paths 51 * </p> 50 52 */ 51 53 private Pattern htmlElementPattern = … … 53 55 54 56 /* (non-Javadoc) 55 * @see de.ugoe.cs.autoquest.plugin.html.AbstractDefaultLogParser#handleGUIElement( java.lang.String, java.util.Map)57 * @see de.ugoe.cs.autoquest.plugin.html.AbstractDefaultLogParser#handleGUIElement(String, Map) 56 58 */ 57 59 @Override … … 149 151 150 152 /* (non-Javadoc) 151 * @see de.ugoe.cs.autoquest.plugin.html.AbstractDefaultLogParser#handleEvent( java.lang.String, java.util.Map)153 * @see de.ugoe.cs.autoquest.plugin.html.AbstractDefaultLogParser#handleEvent(String, Map) 152 154 */ 153 155 @Override … … 201 203 /** 202 204 * <p> 203 * TODO: comment 205 * used to determine the id of a target denoted by an event. This is only required for older 206 * document formats. The new formats use concrete ids. 204 207 * </p> 205 *206 * @param targetDocument207 * @param targetDOMPath208 * @return209 208 */ 210 209 private String determineTargetId(String targetDocument, String targetDOMPath) … … 280 279 * </p> 281 280 * 282 * @param tagName 283 * @return 281 * @param tagName the tag name to check 282 * 283 * @return true, if the tag must be considered, false else 284 284 */ 285 285 private boolean tagNameMustBeConsidered(String tagName) { … … 289 289 !"iframe".equals(tagName) && !"input_hidden".equals(tagName) && 290 290 !"option".equals(tagName) && !"tt".equals(tagName) && !"br".equals(tagName) && 291 !"colgroup".equals(tagName) && !"col".equals(tagName); 291 !"colgroup".equals(tagName) && !"col".equals(tagName) && !"hr".equals(tagName) && 292 !"param".equals(tagName); 292 293 293 294 }
Note: See TracChangeset
for help on using the changeset viewer.