Clover Coverage Report
Coverage timestamp: Fri Feb 14 2014 07:28:57 UTC
../../../../../../img/srcFileCovDistChart9.png 45% of files have more coverage
22   94   14   4.4
16   50   0.64   5
5     2.8  
1    
 
  RenameHandler       Line # 30 22 14 88.4% 0.88372093
 
  (15)
 
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.RenameVo;
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    import 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    */
 
30    public 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  1230 toggle public RenameHandler(final AbstractSimpleHandler handler) {
44  1230 super(handler, "RENAME");
45  1230 subjectVariableHandler = new ElementHandler(this);
46    }
47   
 
48  330 toggle public final void init() {
49  330 rename = null;
50    }
51   
52    /**
53    * Get Rename Bound Subject Variable Rule usage.
54    *
55    * @return Substitute Free Variable usage.
56    */
 
57  330 toggle public final RenameVo getRenameVo() {
58  330 return rename;
59    }
60   
 
61  902 toggle public final void startElement(final String name, final SimpleAttributes attributes)
62    throws XmlSyntaxException {
63  902 if (getStartTag().equals(name)) {
64  330 rename = new RenameVo();
65  330 final String ref = attributes.getString("ref");
66  330 if (ref != null) {
67  297 rename.setReference(ref);
68    }
69  330 final Integer occurrence = attributes.getInteger("occurrence");
70  330 if (occurrence != null) {
71  250 rename.setOccurrence(occurrence.intValue());
72    }
73  572 } else if ("VAR".equals(name)) {
74  572 changeHandler(subjectVariableHandler, name, attributes);
75    } else {
76  0 throw XmlSyntaxException.createUnexpectedTagException(name);
77    }
78    }
79   
 
80  902 toggle public final void endElement(final String name) throws XmlSyntaxException {
81  902 if (getStartTag().equals(name)) {
82    // nothing to do
83  572 } else if ("VAR".equals(name)) {
84  572 if (rename != null && rename.getOriginalSubjectVariable() == null) {
85  297 rename.setOriginalSubjectVariable(subjectVariableHandler.getElement());
86  275 } else if (rename != null) {
87  275 rename.setReplacementSubjectVariable(subjectVariableHandler.getElement());
88    }
89    } else {
90  0 throw XmlSyntaxException.createUnexpectedTagException(name);
91    }
92    }
93   
94    }