EMMA Coverage Report (generated Fri Feb 14 08:28:31 UTC 2014)
[all classes][org.qedeq.kernel.xml.handler.module]

COVERAGE SUMMARY FOR SOURCE FILE [InitialPredicateDefinitionHandler.java]

nameclass, %method, %block, %line, %
InitialPredicateDefinitionHandler.java100% (1/1)100% (6/6)70%  (105/149)78%  (25/32)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class InitialPredicateDefinitionHandler100% (1/1)100% (6/6)70%  (105/149)78%  (25/32)
characters (String, String): void 100% (1/1)43%  (9/21)75%  (3/4)
endElement (String): void 100% (1/1)64%  (28/44)67%  (6/9)
startElement (String, SimpleAttributes): void 100% (1/1)71%  (40/56)73%  (8/11)
InitialPredicateDefinitionHandler (AbstractSimpleHandler): void 100% (1/1)100% (18/18)100% (4/4)
getInitialDefinition (): InitialPredicateDefinition 100% (1/1)100% (3/3)100% (1/1)
init (): void 100% (1/1)100% (7/7)100% (3/3)

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 
16package org.qedeq.kernel.xml.handler.module;
17 
18import org.qedeq.kernel.se.base.module.InitialPredicateDefinition;
19import org.qedeq.kernel.se.dto.module.InitialPredicateDefinitionVo;
20import org.qedeq.kernel.xml.common.XmlSyntaxException;
21import org.qedeq.kernel.xml.handler.common.AbstractSimpleHandler;
22import org.qedeq.kernel.xml.handler.common.SimpleAttributes;
23import org.qedeq.kernel.xml.handler.list.ElementHandler;
24 
25 
26/**
27 * Parse an initial predicate definition.
28 *
29 * @author  Michael Meyling
30 */
31public class InitialPredicateDefinitionHandler extends AbstractSimpleHandler {
32 
33    /** Handler for an element. */
34    private final ElementHandler elementHandler;
35 
36    /** Handler for predicate description. */
37    private final LatexListHandler descriptionHandler;
38 
39    /** Definition value object. */
40    private InitialPredicateDefinitionVo definition;
41 
42    /** LaTeX pattern for the definition. */
43    private String latexPattern;
44 
45 
46    /**
47     * Deals with definitions.
48     *
49     * @param   handler Parent handler.
50     */
51    public InitialPredicateDefinitionHandler(final AbstractSimpleHandler handler) {
52        super(handler, "DEFINITION_PREDICATE_INITIAL");
53        elementHandler = new ElementHandler(this);
54        descriptionHandler = new LatexListHandler(this, "DESCRIPTION");
55    }
56 
57    public final void init() {
58        definition = null;
59        latexPattern = null;
60    }
61 
62    /**
63     * Get definition.
64     *
65     * @return  Definition.
66     */
67    public final InitialPredicateDefinition getInitialDefinition() {
68        return definition;
69    }
70 
71    public final void startElement(final String name, final SimpleAttributes attributes)
72            throws XmlSyntaxException {
73        if (getStartTag().equals(name)) {
74            definition = new InitialPredicateDefinitionVo();
75            definition.setArgumentNumber(attributes.getString("arguments"));
76            definition.setName(attributes.getString("name"));
77        } else if ("LATEXPATTERN".equals(name)) {
78            // nothing to do yet
79        } else if ("PREDCON".equals(name)) {
80            changeHandler(elementHandler, name, attributes);
81        } else if (descriptionHandler.getStartTag().equals(name)) {
82            changeHandler(descriptionHandler, name, attributes);
83        } else {
84            throw XmlSyntaxException.createUnexpectedTagException(name);
85        }
86    }
87 
88    public final void endElement(final String name) throws XmlSyntaxException {
89        if (getStartTag().equals(name)) {
90            // nothing to do
91        } else if ("LATEXPATTERN".equals(name)) {
92            definition.setLatexPattern(latexPattern);
93        } else if ("PREDCON".equals(name)) {
94            definition.setPredCon(elementHandler.getElement());
95        } else if (descriptionHandler.getStartTag().equals(name)) {
96            definition.setDescription(descriptionHandler.getLatexList());
97        } else {
98            throw XmlSyntaxException.createUnexpectedTagException(name);
99        }
100    }
101 
102    public final void characters(final String name, final String data) {
103        if ("LATEXPATTERN".equals(name)) {
104            latexPattern = data;
105        } else {
106            throw new RuntimeException("Unexpected character data in tag: " + name);
107        }
108    }
109 
110 
111}

[all classes][org.qedeq.kernel.xml.handler.module]
EMMA 2.1.5320 (stable) (C) Vladimir Roubtsov