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