Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../../img/srcFileCovDistChart9.png 45% of files have more coverage
14   85   9   2.8
8   39   0.64   5
5     1.8  
1    
 
  AuthorHandler       Line # 29 14 9 85.2% 0.8518519
 
  (102)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.kernel.xml.handler.module;
17   
18    import org.qedeq.kernel.se.dto.module.AuthorVo;
19    import org.qedeq.kernel.xml.common.XmlSyntaxException;
20    import org.qedeq.kernel.xml.handler.common.AbstractSimpleHandler;
21    import org.qedeq.kernel.xml.handler.common.SimpleAttributes;
22   
23    /**
24    * Parse author list.
25    *
26    * @version $Revision: 1.1 $
27    * @author Michael Meyling
28    */
 
29    public class AuthorHandler extends AbstractSimpleHandler {
30   
31    /** Author. */
32    private AuthorVo author;
33   
34    /** Email address of one author. */
35    private String email;
36   
37    /** Parses the name of the author. */
38    private final LatexHandler authorNameHandler;
39   
40   
41    /**
42    * Handles list of authors.
43    *
44    * @param handler Parent handler.
45    */
 
46  614 toggle public AuthorHandler(final AbstractSimpleHandler handler) {
47  614 super(handler, "AUTHOR");
48  614 authorNameHandler = new LatexHandler(this, "NAME");
49    }
50   
 
51  595 toggle public final void init() {
52  595 author = null;
53  595 email = null;
54    }
55   
56    /**
57    * Get author.
58    *
59    * @return Author.
60    */
 
61  595 toggle public final AuthorVo getAuthor() {
62  595 return author;
63    }
64   
 
65  1190 toggle public final void startElement(final String name, final SimpleAttributes attributes)
66    throws XmlSyntaxException {
67  1190 if (getStartTag().equals(name)) {
68  595 email = attributes.getString("email");
69  595 } else if (authorNameHandler.getStartTag().equals(name)) {
70  595 changeHandler(authorNameHandler, name, attributes);
71    } else {
72  0 throw XmlSyntaxException.createUnexpectedTagException(name);
73    }
74    }
75   
 
76  1190 toggle public final void endElement(final String name) throws XmlSyntaxException {
77  1190 if (getStartTag().equals(name)) {
78    // nothing to do
79  595 } else if (authorNameHandler.getStartTag().equals(name)) {
80  595 author = new AuthorVo(authorNameHandler.getLatex(), email);
81    } else {
82  0 throw XmlSyntaxException.createUnexpectedTagException(name);
83    }
84    }
85    }