Ignore:
Timestamp:
06/27/13 09:16:35 (11 years ago)
Author:
pharms
Message:
  • added some documentation
  • corrected handling of unparseable file during compression
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/AbstractDefaultLogParser.java

    r1093 r1232  
    3333import org.xml.sax.Attributes; 
    3434import org.xml.sax.InputSource; 
     35import org.xml.sax.Locator; 
    3536import org.xml.sax.SAXException; 
    3637import org.xml.sax.SAXParseException; 
     
    116117    /** 
    117118     * <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> 
    118126     * Constructor. Creates a new logParser. 
    119127     * </p> 
     
    134142     * @param filename 
    135143     *            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 { 
    138148        if (filename == null) { 
    139149            throw new IllegalArgumentException("filename must not be null"); 
     
    150160     * @param file 
    151161     *            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 { 
    154166        if (file == null) { 
    155167            throw new IllegalArgumentException("file must not be null"); 
     
    167179            Console.printerrln("Error parsing file " + file.getName()); 
    168180            Console.logException(e); 
    169             return; 
     181            throw new SAXParseException("Error parsing file " + file.getName(), locator, e); 
    170182        } 
    171183        catch (ParserConfigurationException e) { 
    172184            Console.printerrln("Error parsing file " + file.getName()); 
    173185            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); 
    179187        } 
    180188        catch (FileNotFoundException e) { 
    181189            Console.printerrln("Error parsing file " + file.getName()); 
    182190            Console.logException(e); 
    183         } 
     191            throw new SAXParseException("Error parsing file " + file.getName(), locator, e); 
     192        } 
     193         
    184194        if (inputSource != null) { 
    185195            inputSource.setSystemId("file://" + file.getAbsolutePath()); 
     
    190200                saxParser.parse(inputSource, this); 
    191201            } 
    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             } 
    202202            catch (IOException e) { 
    203203                Console.printerrln("Error parsing file " + file.getName()); 
    204204                Console.logException(e); 
    205                 return; 
     205                throw new SAXParseException("Error parsing file " + file.getName(), locator, e); 
    206206            } 
    207207        } 
     
    228228    public GUIModel getGuiModel() { 
    229229        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; 
    230238    } 
    231239 
     
    298306    /** 
    299307     * <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 
    306317     */ 
    307318    protected abstract boolean handleGUIElement(String id, Map<String, String> parameters)  
     
    310321    /** 
    311322     * <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 
    318333     */ 
    319334    protected abstract boolean handleEvent(String type, Map<String, String> parameters) 
     
    322337    /** 
    323338     * <p> 
    324      * TODO: comment 
    325      * </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 
    328343     */ 
    329344    protected GUIElementTree<String> getGUIElementTree() { 
     
    333348    /** 
    334349     * <p> 
    335      * TODO: comment 
     350     * adds an event to the currently parsed sequence of events 
    336351     * </p> 
    337352     * 
     
    344359    /** 
    345360     * <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> 
    349367     */ 
    350368    private void processGUIElements() throws SAXException { 
     
    374392    /** 
    375393     * <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> 
    379399     */ 
    380400    private void processEvents() throws SAXException { 
     
    410430    /** 
    411431     * <p> 
    412      * TODO document 
     432     * This class is used internally for storing events and GUI elements in lists. 
    413433     * </p> 
    414434     */ 
Note: See TracChangeset for help on using the changeset viewer.