Clover Coverage Report
Coverage timestamp: Fri Feb 14 2014 01:49:02 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
 
  (4)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2014, 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  147 toggle public HeaderHandler(final AbstractSimpleHandler handler) {
60  147 super(handler, "HEADER");
61  147 titleHandler = new LatexListHandler(this, "TITLE");
62  147 abstractHandler = new LatexListHandler(this, "ABSTRACT");
63  147 specificationHandler = new SpecificationHandler(this);
64  147 authorListHandler = new AuthorListHandler(this);
65  147 importListHandler = new ImportListHandler(this);
66  147 usedbyListHandler = new UsedByListHandler(this);
67    }
68   
 
69  136 toggle public final void init() {
70  136 header = null;
71    }
72   
73    /**
74    * Get header of qedeq module.
75    *
76    * @return Header of qedeq module.
77    */
 
78  136 toggle public final HeaderVo getHeader() {
79  136 return header;
80    }
81   
 
82  799 toggle public final void startElement(final String name, final SimpleAttributes attributes)
83    throws XmlSyntaxException {
84  799 if (getStartTag().equals(name)) {
85  136 header = new HeaderVo();
86  136 header.setEmail(attributes.getString("email"));
87  663 } else if (specificationHandler.getStartTag().equals(name)) {
88  136 changeHandler(specificationHandler, name, attributes);
89  527 } else if (titleHandler.getStartTag().equals(name)) {
90  136 changeHandler(titleHandler, name, attributes);
91  391 } else if (abstractHandler.getStartTag().equals(name)) {
92  136 changeHandler(abstractHandler, name, attributes);
93  255 } else if (authorListHandler.getStartTag().equals(name)) {
94  136 changeHandler(authorListHandler, name, attributes);
95  119 } else if (importListHandler.getStartTag().equals(name)) {
96  92 changeHandler(importListHandler, name, attributes);
97  27 } else if (usedbyListHandler.getStartTag().equals(name)) {
98  27 changeHandler(usedbyListHandler, name, attributes);
99    } else {
100  0 throw XmlSyntaxException.createUnexpectedTagException(name);
101    }
102    }
103   
 
104  799 toggle public final void endElement(final String name) throws XmlSyntaxException {
105  799 if (getStartTag().equals(name)) {
106    // nothing to do
107  663 } else if (specificationHandler.getStartTag().equals(name)) {
108  136 header.setSpecification(specificationHandler.getSpecification());
109  527 } else if (titleHandler.getStartTag().equals(name)) {
110  136 header.setTitle(titleHandler.getLatexList());
111  391 } else if (abstractHandler.getStartTag().equals(name)) {
112  136 header.setSummary(abstractHandler.getLatexList());
113  255 } else if (authorListHandler.getStartTag().equals(name)) {
114  136 header.setAuthorList(authorListHandler.getAuthorList());
115  119 } else if (importListHandler.getStartTag().equals(name)) {
116  92 header.setImportList(importListHandler.getImportList());
117  27 } else if (usedbyListHandler.getStartTag().equals(name)) {
118  27 header.setUsedByList(usedbyListHandler.getUsedByList());
119    } else {
120  0 throw XmlSyntaxException.createUnexpectedTagException(name);
121    }
122    }
123   
124    }