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 [RenameHandler.java]

nameclass, %method, %block, %line, %
RenameHandler.java100% (1/1)100% (5/5)94%  (97/103)92%  (24/26)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class RenameHandler100% (1/1)100% (5/5)94%  (97/103)92%  (24/26)
endElement (String): void 100% (1/1)92%  (35/38)88%  (7/8)
startElement (String, SimpleAttributes): void 100% (1/1)94%  (44/47)92%  (11/12)
RenameHandler (AbstractSimpleHandler): void 100% (1/1)100% (11/11)100% (3/3)
getRenameVo (): RenameVo 100% (1/1)100% (3/3)100% (1/1)
init (): void 100% (1/1)100% (4/4)100% (2/2)

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.dto.module.RenameVo;
19import org.qedeq.kernel.xml.common.XmlSyntaxException;
20import org.qedeq.kernel.xml.handler.common.AbstractSimpleHandler;
21import org.qedeq.kernel.xml.handler.common.SimpleAttributes;
22import org.qedeq.kernel.xml.handler.list.ElementHandler;
23 
24 
25/**
26 * Parse a Rename Bound Subject Variable Rule usage.
27 *
28 * @author  Michael Meyling
29 */
30public class RenameHandler extends AbstractSimpleHandler {
31 
32    /** Rule value object. */
33    private RenameVo rename;
34 
35    /** Handle subject variables. */
36    private final ElementHandler subjectVariableHandler;
37 
38    /**
39     * Deals with definitions.
40     *
41     * @param   handler Parent handler.
42     */
43    public RenameHandler(final AbstractSimpleHandler handler) {
44        super(handler, "RENAME");
45        subjectVariableHandler = new ElementHandler(this);
46    }
47 
48    public final void init() {
49        rename = null;
50    }
51 
52    /**
53     * Get Rename Bound Subject Variable Rule usage.
54     *
55     * @return  Substitute Free Variable usage.
56     */
57    public final RenameVo getRenameVo() {
58        return rename;
59    }
60 
61    public final void startElement(final String name, final SimpleAttributes attributes)
62            throws XmlSyntaxException {
63        if (getStartTag().equals(name)) {
64            rename = new RenameVo();
65            final String ref = attributes.getString("ref");
66            if (ref != null) {
67                rename.setReference(ref);
68            }
69            final Integer occurrence = attributes.getInteger("occurrence");
70            if (occurrence != null) {
71                rename.setOccurrence(occurrence.intValue());
72            }
73        } else if ("VAR".equals(name)) {
74            changeHandler(subjectVariableHandler, name, attributes);
75        } else {
76            throw XmlSyntaxException.createUnexpectedTagException(name);
77        }
78    }
79 
80    public final void endElement(final String name) throws XmlSyntaxException {
81        if (getStartTag().equals(name)) {
82            // nothing to do
83        } else if ("VAR".equals(name)) {
84            if (rename != null && rename.getOriginalSubjectVariable() == null) {
85                rename.setOriginalSubjectVariable(subjectVariableHandler.getElement());
86            } else if (rename != null) {
87                rename.setReplacementSubjectVariable(subjectVariableHandler.getElement());
88            }
89        } else {
90            throw XmlSyntaxException.createUnexpectedTagException(name);
91        }
92    }
93 
94}

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