Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../../img/srcFileCovDistChart8.png 62% of files have more coverage
16   95   10   2.67
8   44   0.62   6
6     1.67  
1    
 
  BasicHandler       Line # 31 16 10 73.3% 0.73333335
 
  (288)
 
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.list;
17   
18    import java.util.ArrayList;
19    import java.util.List;
20   
21    import org.qedeq.kernel.xml.common.XmlSyntaxException;
22    import org.qedeq.kernel.xml.handler.common.AbstractSimpleHandler;
23    import org.qedeq.kernel.xml.handler.common.SaxDefaultHandler;
24    import org.qedeq.kernel.xml.handler.common.SimpleAttributes;
25   
26    /**
27    * Parse unknown number of elements.
28    *
29    * @author Michael Meyling
30    */
 
31    public class BasicHandler extends AbstractSimpleHandler {
32   
33    /** Our parsed elements. */
34    private List elements;
35   
36    /** Handles {@link org.qedeq.kernel.se.base.list.Element}s. */
37    private final ElementHandler elementHandler;
38   
39   
40    /**
41    * Deals with elements.
42    *
43    * @param handler Parent handler.
44    */
 
45  447 toggle public BasicHandler(final SaxDefaultHandler handler) {
46  447 super(handler, "basic");
47  447 elements = new ArrayList();
48  447 elementHandler = new ElementHandler(this);
49    }
50   
51    /**
52    * Handles formulas.
53    *
54    * @param handler Parent handler.
55    */
 
56  0 toggle public BasicHandler(final AbstractSimpleHandler handler) {
57  0 super(handler, "basic");
58  0 elements = new ArrayList();
59  0 elementHandler = new ElementHandler(this);
60    }
61   
 
62  447 toggle public final void init() {
63  447 elements.clear();
64    }
65   
66    /**
67    * Get parsed result.
68    *
69    * @return List of elements.
70    */
 
71  447 toggle public final List getElements() {
72  447 return elements;
73    }
74   
 
75  894 toggle public final void startElement(final String name, final SimpleAttributes attributes)
76    throws XmlSyntaxException {
77  894 if (getStartTag().equals(name)) {
78    // nothing to do
79  447 } else if (getLevel() > 1) {
80  447 changeHandler(elementHandler, name, attributes);
81    } else {
82  0 throw XmlSyntaxException.createUnexpectedTagException(name);
83    }
84    }
85   
 
86  894 toggle public final void endElement(final String name) throws XmlSyntaxException {
87  894 if (getStartTag().equals(name)) {
88    // nothing to do, we are ready!
89  447 } else if (getLevel() <= 1) {
90  0 throw XmlSyntaxException.createUnexpectedTagException(name);
91    } else {
92  447 elements.add(elementHandler.getElement());
93    }
94    }
95    }