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

COVERAGE SUMMARY FOR SOURCE FILE [KernelNodeBo.java]

nameclass, %method, %block, %line, %
KernelNodeBo.java100% (1/1)88%  (14/16)84%  (223/267)79%  (55.6/70)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class KernelNodeBo100% (1/1)88%  (14/16)84%  (223/267)79%  (55.6/70)
getModuleContext (): ModuleContext 0%   (0/1)0%   (0/3)0%   (0/1)
getParentQedeqBo (): QedeqBo 0%   (0/1)0%   (0/3)0%   (0/1)
getFormula (): Element 100% (1/1)58%  (41/71)50%  (10/20)
isNotProved (): boolean 100% (1/1)82%  (9/11)81%  (0.8/1)
hasFormula (): boolean 100% (1/1)88%  (7/8)87%  (0.9/1)
isWellFormed (): boolean 100% (1/1)88%  (7/8)87%  (0.9/1)
isProofLineLabel (String): boolean 100% (1/1)96%  (43/45)92%  (12/13)
hasProofLineLabel (String, FormalProofLineList): boolean 100% (1/1)96%  (53/55)93%  (14/15)
KernelNodeBo (NodeVo, ModuleContext, KernelQedeqBo, QedeqNumbers): void 100% (1/1)100% (27/27)100% (8/8)
getNodeVo (): NodeVo 100% (1/1)100% (3/3)100% (1/1)
getNumbers (): QedeqNumbers 100% (1/1)100% (3/3)100% (1/1)
getQedeqBo (): KernelQedeqBo 100% (1/1)100% (3/3)100% (1/1)
isNotWellFormed (): boolean 100% (1/1)100% (11/11)100% (1/1)
isProved (): boolean 100% (1/1)100% (8/8)100% (1/1)
setProved (int): void 100% (1/1)100% (4/4)100% (2/2)
setWellFormed (int): 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.bo.module;
17 
18import org.qedeq.kernel.bo.common.NodeBo;
19import org.qedeq.kernel.bo.common.QedeqBo;
20import org.qedeq.kernel.se.base.list.Element;
21import org.qedeq.kernel.se.base.module.ConditionalProof;
22import org.qedeq.kernel.se.base.module.FormalProofLineList;
23import org.qedeq.kernel.se.base.module.FormalProofList;
24import org.qedeq.kernel.se.base.module.NodeType;
25import org.qedeq.kernel.se.base.module.Proposition;
26import org.qedeq.kernel.se.base.module.Reason;
27import org.qedeq.kernel.se.common.CheckLevel;
28import org.qedeq.kernel.se.common.ModuleContext;
29import org.qedeq.kernel.se.dto.module.NodeVo;
30import org.qedeq.kernel.se.visitor.QedeqNumbers;
31 
32/**
33 * Business object for node access.
34 *
35 * @author  Michael Meyling
36 */
37public class KernelNodeBo implements NodeBo, CheckLevel {
38 
39    /** The plain node data. */
40    private final NodeVo node;
41 
42    /** The module context the node is within. */
43    private final ModuleContext context;
44 
45    /** Parent module the node is within. */
46    private final KernelQedeqBo qedeq;
47 
48    /** Herein are the results of various counters for the node. */
49    private final QedeqNumbers data;
50 
51    /** Are all formal formulas of this node well formed.
52     * See {@link CheckLevel} for value format. */
53    private int wellFormedCheck = UNCHECKED;
54 
55    /** Is this node been successfully formally proved at least once.
56     * See {@link CheckLevel} for value format. */
57    private int provedCheck = UNCHECKED;
58 
59 
60    /**
61     * Constructor.
62     *
63     * @param   node    The plain node data.
64     * @param   context The module context the node is within.
65     * @param   qedeq   Parent module the node is within.
66     * @param   data    Herein are the results of various counters for the node.
67     */
68    public KernelNodeBo(final NodeVo node, final ModuleContext context, final KernelQedeqBo qedeq,
69            final QedeqNumbers data) {
70        this.node = node;
71        this.context = new ModuleContext(context);
72        this.qedeq = qedeq;
73        this.data = new QedeqNumbers(data);
74    }
75 
76    /**
77     * Get plain node data.
78     *
79     * @return  The plain node data.
80     */
81    public NodeVo getNodeVo() {
82        return node;
83    }
84 
85    /**
86     * Get module context the node is within.
87     *
88     * @return  The module context the node is within.
89     */
90    public ModuleContext getModuleContext() {
91        return context;
92    }
93 
94    /**
95     * Get parent module the node is within.
96     *
97     * @return  Parent module the node is within.
98     */
99    public QedeqBo getParentQedeqBo() {
100        return qedeq;
101    }
102 
103    /**
104     * Get parent module the node is within.
105     *
106     * @return  Parent module the node is within.
107     */
108    public KernelQedeqBo getQedeqBo() {
109        return qedeq;
110    }
111 
112    /**
113     * Get the results of various counters for the node.
114     *
115     * @return  Herein are the results of various counters for the node.
116     */
117    public QedeqNumbers getNumbers() {
118        return data;
119    }
120 
121    /**
122     * // FIXME 20110316 m31: we have to solve the uniqueness problem if we have several formal proofs
123     * Is the given name a proof line label within this node?
124     *
125     * @param   label   Look if this node is a proposition that contains this label name.
126     * @return  Answer.
127     */
128    public boolean isProofLineLabel(final String label) {
129        if (label == null || label.length() == 0) {
130            return false;
131        }
132        final Proposition theorem = getNodeVo().getNodeType().getProposition();
133        if (theorem == null) {
134            return false;
135        }
136        final FormalProofList proofs = theorem.getFormalProofList();
137        if (proofs == null) {
138            return false;
139        }
140        // iterate through all formal proofs
141        for (int i = 0; i < proofs.size(); i++) {
142            final FormalProofLineList list = proofs.get(i).getFormalProofLineList();
143            if (hasProofLineLabel(label, list)) {
144                return true;
145            }
146        }
147        // nowhere found:
148        return false;
149    }
150 
151    private boolean hasProofLineLabel(final String label, final FormalProofLineList list) {
152        if (list == null) {
153            return false;
154        }
155        for (int j = 0; j < list.size(); j++) {
156            if (label.equals(list.get(j).getLabel())) {
157                return true;
158            }
159            final Reason reason = list.get(j).getReason();
160            if (reason instanceof ConditionalProof) {
161                final ConditionalProof conditionalProof = (ConditionalProof) reason;
162                if (conditionalProof.getHypothesis() != null) {
163                    if (label.equals(conditionalProof.getHypothesis().getLabel())) {
164                        return true;
165                    }
166                }
167                final FormalProofLineList list2 = conditionalProof.getFormalProofLineList();
168                if (hasProofLineLabel(label, list2)) {
169                    return true;
170                }
171            }
172        }
173        return false;
174    }
175 
176    /**
177     * Set proved parameter. See {@link #isWellFormed()}.
178     *
179     * @param   wellFormedCheck     Node well formed state.
180     *          See {@link CheckLevel} for parameter format.
181     */
182    public void setWellFormed(final int wellFormedCheck) {
183        this.wellFormedCheck = wellFormedCheck;
184    }
185 
186    public boolean isWellFormed() {
187        return wellFormedCheck >= SUCCESS;
188    }
189 
190    public boolean isNotWellFormed() {
191        return wellFormedCheck < SUCCESS && wellFormedCheck > UNCHECKED;
192    }
193 
194    /**
195     * Set proved parameter. See {@link #isProved()}.
196     *
197     * @param   provedCheck     Node proved state.
198     *          See {@link CheckLevel} for parameter format.
199     */
200    public void setProved(final int provedCheck) {
201        this.provedCheck = provedCheck;
202    }
203 
204    public boolean isProved() {
205        return provedCheck >= SUCCESS;
206    }
207 
208    public boolean isNotProved() {
209        return provedCheck < SUCCESS && provedCheck > UNCHECKED;
210    }
211 
212    public boolean hasFormula() {
213        return null != getFormula();
214    }
215 
216    public Element getFormula() {
217        if (getNodeVo() == null || getNodeVo().getNodeType() == null) {
218            return null;
219        }
220        final NodeType nodeType = getNodeVo().getNodeType();
221        if (nodeType.getProposition() != null) {
222            if (nodeType.getProposition().getFormula() != null) {
223                return nodeType.getProposition().getFormula().getElement();
224            }
225            return null;
226        } else if (nodeType.getPredicateDefinition() != null) {
227            if (nodeType.getPredicateDefinition().getFormula() != null) {
228                return nodeType.getPredicateDefinition().getFormula().getElement();
229            }
230            return null;
231        } else if (nodeType.getFunctionDefinition() != null) {
232            if (nodeType.getFunctionDefinition().getFormula() != null) {
233                return nodeType.getFunctionDefinition().getFormula().getElement();
234            }
235            return null;
236        } else if (nodeType.getAxiom() != null) {
237            if (nodeType.getAxiom().getFormula() != null) {
238                return nodeType.getAxiom().getFormula().getElement();
239            }
240            return null;
241        }
242        return null;
243    }
244}

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