Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 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
 
  (13)
 
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.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  1064 toggle public RenameHandler(final AbstractSimpleHandler handler) {
44  1064 super(handler, "RENAME");
45  1064 subjectVariableHandler = new ElementHandler(this);
46    }
47   
 
48  314 toggle public final void init() {
49  314 rename = null;
50    }
51   
52    /**
53    * Get Rename Bound Subject Variable Rule usage.
54    *
55    * @return Substitute Free Variable usage.
56    */
 
57  314 toggle public final RenameVo getRenameVo() {
58  314 return rename;
59    }
60   
 
61  854 toggle public final void startElement(final String name, final SimpleAttributes attributes)
62    throws XmlSyntaxException {
63  854 if (getStartTag().equals(name)) {
64  314 rename = new RenameVo();
65  314 final String ref = attributes.getString("ref");
66  314 if (ref != null) {
67  281 rename.setReference(ref);
68    }
69  314 final Integer occurrence = attributes.getInteger("occurrence");
70  314 if (occurrence != null) {
71  234 rename.setOccurrence(occurrence.intValue());
72    }
73  540 } else if ("VAR".equals(name)) {
74  540 changeHandler(subjectVariableHandler, name, attributes);
75    } else {
76  0 throw XmlSyntaxException.createUnexpectedTagException(name);
77    }
78    }
79   
 
80  854 toggle public final void endElement(final String name) throws XmlSyntaxException {
81  854 if (getStartTag().equals(name)) {
82    // nothing to do
83  540 } else if ("VAR".equals(name)) {
84  540 if (rename != null && rename.getOriginalSubjectVariable() == null) {
85  281 rename.setOriginalSubjectVariable(subjectVariableHandler.getElement());
86  259 } else if (rename != null) {
87  259 rename.setReplacementSubjectVariable(subjectVariableHandler.getElement());
88    }
89    } else {
90  0 throw XmlSyntaxException.createUnexpectedTagException(name);
91    }
92    }
93   
94    }