Changeset 1232 for trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/AbstractDefaultLogParser.java
- Timestamp:
- 06/27/13 09:16:35 (11 years ago)
- File:
-
- 1 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 */
Note: See TracChangeset
for help on using the changeset viewer.