Clover Coverage Report
Coverage timestamp: Sat Sep 18 2010 04:09:52 UTC
../../../../../img/srcFileCovDistChart9.png 34% of files have more coverage
30   205   22   1.43
14   101   0.73   21
21     1.05  
1    
 
  PredicateDefinitionVo       Line # 39 30 22 87.7% 0.8769231
 
  (42)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2010, 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.dto.module;
17   
18    import org.qedeq.base.utility.EqualsUtility;
19    import org.qedeq.kernel.base.module.Axiom;
20    import org.qedeq.kernel.base.module.Formula;
21    import org.qedeq.kernel.base.module.FunctionDefinition;
22    import org.qedeq.kernel.base.module.LatexList;
23    import org.qedeq.kernel.base.module.PredicateDefinition;
24    import org.qedeq.kernel.base.module.Proposition;
25    import org.qedeq.kernel.base.module.Rule;
26    import org.qedeq.kernel.base.module.VariableList;
27   
28   
29    /**
30    * Definition of operator. This is a predicate constant. For example the
31    * predicate "x is a set" could be defined in MK with the formula "\exists y: x \in y".
32    * <p>
33    * There must also be the possibility to define basic predicate constants like
34    * "x is element of y".
35    *
36    * @version $Revision: 1.6 $
37    * @author Michael Meyling
38    */
 
39    public class PredicateDefinitionVo implements PredicateDefinition {
40   
41    /** Carries information about the argument number the defined object needs. */
42    private String argumentNumber;
43   
44    /** This name together with argumentNumber identifies a function. */
45    private String name;
46   
47    /** LaTeX pattern for definition visualisation. The replaceable arguments must are
48    * marked as <code>#1</code>, <code>#2</code> and so on. For example
49    * <code>\mathfrak{M}(#1)</code> */
50    private String latexPattern;
51   
52    /** List of formula or subject variables to be replaced in the LaTeX pattern.
53    * Could be <code>null</code>.*/
54    private VariableList variableList;
55   
56    /** Formula or term that defines the object. Could be <code>null</code>. */
57    private Formula formula;
58   
59    /** Further proposition description. Normally <code>null</code>. */
60    private LatexList description;
61   
62    /**
63    * Constructs a new definition.
64    */
 
65  698 toggle public PredicateDefinitionVo() {
66    // nothing to do
67    }
68   
 
69  0 toggle public Axiom getAxiom() {
70  0 return null;
71    }
72   
 
73  1766 toggle public PredicateDefinition getPredicateDefinition() {
74  1766 return this;
75    }
76   
 
77  0 toggle public FunctionDefinition getFunctionDefinition() {
78  0 return null;
79    }
80   
 
81  0 toggle public Proposition getProposition() {
82  0 return null;
83    }
84   
 
85  0 toggle public Rule getRule() {
86  0 return null;
87    }
88   
89    /**
90    * Set information about the argument number the defined object needs.
91    *
92    * @param argumentNumber Argument number information.
93    */
 
94  654 toggle public final void setArgumentNumber(final String argumentNumber) {
95  654 this.argumentNumber = argumentNumber;
96    }
97   
 
98  2472 toggle public final String getArgumentNumber() {
99  2472 return argumentNumber;
100    }
101   
102    /**
103    * Set predicate name. Together with {@link #getArgumentNumber()} this
104    * identifies a predicate.
105    *
106    * @param name Predicate name.
107    */
 
108  654 toggle public void setName(final String name) {
109  654 this.name = name;
110    }
111   
 
112  2430 toggle public String getName() {
113  2430 return name;
114    }
115   
116    /**
117    * Set LaTeX pattern for definition visualisation. The replaceable arguments are
118    * marked as <code>#1</code>, <code>#2</code> and so on. For example
119    * <code>\mathfrak{M}(#1)</code>.
120    *
121    * @param latexPattern LaTeX pattern for definition visualisation.
122    */
 
123  654 toggle public final void setLatexPattern(final String latexPattern) {
124  654 this.latexPattern = latexPattern;
125    }
126   
 
127  3462 toggle public final String getLatexPattern() {
128  3462 return latexPattern;
129    }
130   
131    /**
132    * Set list of formula or subject variables to be replaced in the LaTeX pattern.
133    * Could be <code>null</code>.
134    *
135    * @param variables Variable list for replacement.
136    */
 
137  570 toggle public final void setVariableList(final VariableListVo variables) {
138  570 this.variableList = variables;
139    }
140   
 
141  7206 toggle public final VariableList getVariableList() {
142  7206 return variableList;
143    }
144   
145    /**
146    * Set defining formula or term that defines the object. Could be <code>null</code>.
147    *
148    * @param formulaOrTerm Formula or term that defines the new operator.
149    */
 
150  449 toggle public final void setFormula(final FormulaVo formulaOrTerm) {
151  449 this.formula = formulaOrTerm;
152    }
153   
 
154  7564 toggle public final Formula getFormula() {
155  7564 return formula;
156    }
157   
158    /**
159    * Set description. Only necessary if formula is not self-explanatory.
160    *
161    * @param description Description.
162    */
 
163  113 toggle public final void setDescription(final LatexListVo description) {
164  113 this.description = description;
165    }
166   
 
167  2632 toggle public LatexList getDescription() {
168  2632 return description;
169    }
170   
 
171  252 toggle public boolean equals(final Object obj) {
172  252 if (!(obj instanceof PredicateDefinition)) {
173  10 return false;
174    }
175  242 final PredicateDefinition other = (PredicateDefinition) obj;
176  242 return EqualsUtility.equals(getArgumentNumber(), other.getArgumentNumber())
177    && EqualsUtility.equals(getName(), other.getName())
178    && EqualsUtility.equals(getLatexPattern(), other.getLatexPattern())
179    && EqualsUtility.equals(getVariableList(), other.getVariableList())
180    && EqualsUtility.equals(getFormula(), other.getFormula())
181    && EqualsUtility.equals(getDescription(), other.getDescription());
182    }
183   
 
184  359 toggle public int hashCode() {
185  359 return (getArgumentNumber() != null ? getArgumentNumber().hashCode() : 0)
186  359 ^ (getName() != null ? 1 ^ getName().hashCode() : 0)
187  359 ^ (getLatexPattern() != null ? 2 ^ getLatexPattern().hashCode() : 0)
188  359 ^ (getVariableList() != null ? 3 ^ getVariableList().hashCode() : 0)
189  359 ^ (getFormula() != null ? 4 ^ getFormula().hashCode() : 0)
190  359 ^ (getDescription() != null ? 5 ^ getDescription().hashCode() : 0);
191    }
192   
 
193  270 toggle public String toString() {
194  270 final StringBuffer buffer = new StringBuffer();
195  270 buffer.append("Predicate Definition arguments=" + getArgumentNumber() + "\n");
196  270 buffer.append("\tname=" + getName() + "\n");
197  270 buffer.append("\tpattern=" + getLatexPattern() + "\n");
198  270 buffer.append("\tvariables=" + getVariableList() + "\n");
199  270 buffer.append("\tformula/term:\n" + getFormula() + "\n");
200  270 buffer.append("\tdescription:\n" + getDescription() + "\n");
201  270 return buffer.toString();
202    }
203   
204   
205    }