Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
39   124   19   7.8
28   68   0.49   5
5     3.8  
1    
 
  HeaderHandler       Line # 30 39 19 94.4% 0.9444444
 
  (96)
 
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.HeaderVo;
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    /**
25    * Parse header informations.
26    *
27    * @version $Revision: 1.1 $
28    * @author Michael Meyling
29    */
 
30    public class HeaderHandler extends AbstractSimpleHandler {
31   
32    /** Value object for module header. */
33    private HeaderVo header;
34   
35    /** Handler for module specification. */
36    private final SpecificationHandler specificationHandler;
37   
38    /** Handler for module title. */
39    private final LatexListHandler titleHandler;
40   
41    /** Handler for module abstract. */
42    private final LatexListHandler abstractHandler;
43   
44    /** Handler for list of module authors. */
45    private final AuthorListHandler authorListHandler;
46   
47    /** Handler for list of module imports. */
48    private final ImportListHandler importListHandler;
49   
50    /** Handler for list of modules that need this one. */
51    private final UsedByListHandler usedbyListHandler;
52   
53   
54    /**
55    * Deals with header of qedeq file.
56    *
57    * @param handler Parent handler.
58    */
 
59  614 toggle public HeaderHandler(final AbstractSimpleHandler handler) {
60  614 super(handler, "HEADER");
61  614 titleHandler = new LatexListHandler(this, "TITLE");
62  614 abstractHandler = new LatexListHandler(this, "ABSTRACT");
63  614 specificationHandler = new SpecificationHandler(this);
64  614 authorListHandler = new AuthorListHandler(this);
65  614 importListHandler = new ImportListHandler(this);
66  614 usedbyListHandler = new UsedByListHandler(this);
67    }
68   
 
69  595 toggle public final void init() {
70  595 header = null;
71    }
72   
73    /**
74    * Get header of qedeq module.
75    *
76    * @return Header of qedeq module.
77    */
 
78  595 toggle public final HeaderVo getHeader() {
79  595 return header;
80    }
81   
 
82  3490 toggle public final void startElement(final String name, final SimpleAttributes attributes)
83    throws XmlSyntaxException {
84  3490 if (getStartTag().equals(name)) {
85  595 header = new HeaderVo();
86  595 header.setEmail(attributes.getString("email"));
87  2895 } else if (specificationHandler.getStartTag().equals(name)) {
88  595 changeHandler(specificationHandler, name, attributes);
89  2300 } else if (titleHandler.getStartTag().equals(name)) {
90  595 changeHandler(titleHandler, name, attributes);
91  1705 } else if (abstractHandler.getStartTag().equals(name)) {
92  595 changeHandler(abstractHandler, name, attributes);
93  1110 } else if (authorListHandler.getStartTag().equals(name)) {
94  595 changeHandler(authorListHandler, name, attributes);
95  515 } else if (importListHandler.getStartTag().equals(name)) {
96  370 changeHandler(importListHandler, name, attributes);
97  145 } else if (usedbyListHandler.getStartTag().equals(name)) {
98  145 changeHandler(usedbyListHandler, name, attributes);
99    } else {
100  0 throw XmlSyntaxException.createUnexpectedTagException(name);
101    }
102    }
103   
 
104  3490 toggle public final void endElement(final String name) throws XmlSyntaxException {
105  3490 if (getStartTag().equals(name)) {
106    // nothing to do
107  2895 } else if (specificationHandler.getStartTag().equals(name)) {
108  595 header.setSpecification(specificationHandler.getSpecification());
109  2300 } else if (titleHandler.getStartTag().equals(name)) {
110  595 header.setTitle(titleHandler.getLatexList());
111  1705 } else if (abstractHandler.getStartTag().equals(name)) {
112  595 header.setSummary(abstractHandler.getLatexList());
113  1110 } else if (authorListHandler.getStartTag().equals(name)) {
114  595 header.setAuthorList(authorListHandler.getAuthorList());
115  515 } else if (importListHandler.getStartTag().equals(name)) {
116  370 header.setImportList(importListHandler.getImportList());
117  145 } else if (usedbyListHandler.getStartTag().equals(name)) {
118  145 header.setUsedByList(usedbyListHandler.getUsedByList());
119    } else {
120  0 throw XmlSyntaxException.createUnexpectedTagException(name);
121    }
122    }
123   
124    }