Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Dez 29 2005 18:38:29 CET
file stats: LOC: 198   Methods: 20
NCLOC: 96   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DefinitionBo.java 100% 85,7% 80% 87,1%
coverage coverage
 1    /* $Id: DefinitionBo.java,v 1.6 2005/12/09 18:23:32 m31 Exp $
 2    *
 3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
 4    *
 5    * Copyright 2000-2005, Michael Meyling <mime@qedeq.org>.
 6    *
 7    * "Hilbert II" is free software; you can redistribute
 8    * it and/or modify it under the terms of the GNU General Public
 9    * License as published by the Free Software Foundation; either
 10    * version 2 of the License, or (at your option) any later version.
 11    *
 12    * This program is distributed in the hope that it will be useful,
 13    * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 15    * GNU General Public License for more details.
 16    */
 17   
 18    package org.qedeq.kernel.bo.module;
 19   
 20    import org.qedeq.kernel.base.module.Axiom;
 21    import org.qedeq.kernel.base.module.Definition;
 22    import org.qedeq.kernel.base.module.FormulaOrTerm;
 23    import org.qedeq.kernel.base.module.LatexList;
 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    import org.qedeq.kernel.utility.EqualsUtility;
 28   
 29   
 30    /**
 31    * Definition of operator. This might be a predicate or function constant. For example the
 32    * predicate "x is a set" could be defined in MK with the formulaOrTerm "\exists y: x \in y".
 33    * <p>
 34    * There must also be the possibility to define basic predicate constants like "x is element
 35    * of y".
 36    *
 37    * @version $Revision: 1.6 $
 38    * @author Michael Meyling
 39    */
 40    public final class DefinitionBo implements Definition {
 41   
 42    /** Definition type. For example: this a predicate definition, a function definition. */
 43    private String type;
 44   
 45    /** Carries information about the argument number the defined object needs. */
 46    private String argumentNumber;
 47   
 48    /** LaTeX pattern for definition visualisation. The replaceable arguments must are marked as
 49    * <code>#1</code>, <code>#2</code> and so on. For example <code>\mathfrak{M}(#1)</code>. */
 50    private String latexPattern;
 51   
 52    /** List of formula or subject variables to be replaced in the LaTeX pattern. Could be
 53    * <code>null</code>.*/
 54    private VariableList variableList;
 55   
 56    /** Formula or term that defines the object. Could be <code>null</code>. */
 57    private FormulaOrTerm formulaOrTerm;
 58   
 59    /** Further proposition description. Normally <code>null</code>. */
 60    private LatexList description;
 61   
 62    /**
 63    * Constructs a new definition.
 64    */
 65  169 public DefinitionBo() {
 66    // nothing to do
 67    }
 68   
 69  0 public Axiom getAxiom() {
 70  0 return null;
 71    }
 72   
 73  0 public Definition getDefinition() {
 74  0 return this;
 75    }
 76   
 77  0 public Proposition getProposition() {
 78  0 return null;
 79    }
 80   
 81  0 public Rule getRule() {
 82  0 return null;
 83    }
 84   
 85    /**
 86    * Set definition type. For example: this a predicate definition, a function definition.
 87    *
 88    * @param type Definition type.
 89    */
 90  127 public final void setType(final String type) {
 91  127 this.type = type;
 92    }
 93   
 94  901 public final String getType() {
 95  901 return type;
 96    }
 97   
 98    /**
 99    * Set information about the argument number the defined object needs.
 100    *
 101    * @param argumentNumber Argument number of this definition.
 102    */
 103  127 public final void setArgumentNumber(final String argumentNumber) {
 104  127 this.argumentNumber = argumentNumber;
 105    }
 106   
 107  883 public final String getArgumentNumber() {
 108  883 return argumentNumber;
 109    }
 110   
 111    /**
 112    * Set LaTeX pattern for definition visualisation. The replaceable arguments must are marked
 113    * as <code>#1</code>, <code>#2</code> and so on. For example <code>\mathfrak{M}(#1)</code>.
 114    *
 115    *
 116    * @param latexPattern LaTeX pattern for definition visualisation.
 117    */
 118  127 public final void setLatexPattern(final String latexPattern) {
 119  127 this.latexPattern = latexPattern;
 120    }
 121   
 122  935 public final String getLatexPattern() {
 123  935 return latexPattern;
 124    }
 125   
 126    /**
 127    * Set list of formula or subject variables to be replaced in the LaTeX pattern. Could be
 128    * <code>null</code>.
 129    *
 130    * @param variables Pattern replacement variables.
 131    */
 132  127 public final void setVariableList(final VariableList variables) {
 133  127 this.variableList = variables;
 134    }
 135   
 136  861 public final VariableList getVariableList() {
 137  861 return variableList;
 138    }
 139   
 140    /**
 141    * Set formula or term that defines the object. Could be <code>null</code>.
 142    *
 143    * @param formulaOrTerm Defining formula or term.
 144    */
 145  120 public final void setFormulaOrTerm(final FormulaOrTerm formulaOrTerm) {
 146  120 this.formulaOrTerm = formulaOrTerm;
 147    }
 148   
 149  861 public final FormulaOrTerm getFormulaOrTerm() {
 150  861 return formulaOrTerm;
 151    }
 152   
 153    /**
 154    * Set description. Only necessary if formula is not self-explanatory.
 155    *
 156    * @param description Description.
 157    */
 158  111 public final void setDescription(final LatexList description) {
 159  111 this.description = description;
 160    }
 161   
 162  885 public LatexList getDescription() {
 163  885 return description;
 164    }
 165   
 166  203 public boolean equals(final Object obj) {
 167  203 if (!(obj instanceof Definition)) {
 168  10 return false;
 169    }
 170  193 final Definition other = (Definition) obj;
 171  193 return EqualsUtility.equals(getType(), other.getType())
 172    && EqualsUtility.equals(getArgumentNumber(), other.getArgumentNumber())
 173    && EqualsUtility.equals(getLatexPattern(), other.getLatexPattern())
 174    && EqualsUtility.equals(getVariableList(), other.getVariableList())
 175    && EqualsUtility.equals(getFormulaOrTerm(), other.getFormulaOrTerm())
 176    && EqualsUtility.equals(getDescription(), other.getDescription());
 177    }
 178   
 179  203 public int hashCode() {
 180  203 return (getType() != null ? getType().hashCode() : 0)
 181  203 ^ (getArgumentNumber() != null ? getArgumentNumber().hashCode() : 0)
 182  203 ^ (getLatexPattern() != null ? 1 ^ getLatexPattern().hashCode() : 0)
 183  203 ^ (getVariableList() != null ? 2 ^ getVariableList().hashCode() : 0)
 184  203 ^ (getFormulaOrTerm() != null ? 3 ^ getFormulaOrTerm().hashCode() : 0)
 185  203 ^ (getDescription() != null ? 4 ^ getDescription().hashCode() : 0);
 186    }
 187   
 188  154 public String toString() {
 189  154 final StringBuffer buffer = new StringBuffer();
 190  154 buffer.append("Definition Type=" + getType() + " arguments=" + getArgumentNumber() + "\n");
 191  154 buffer.append("\tpattern=" + getLatexPattern() + "\n");
 192  154 buffer.append("\tvariables=" + getVariableList() + "\n");
 193  154 buffer.append("\tformula/term:\n" + getFormulaOrTerm() + "\n");
 194  154 buffer.append("\tdescription=" + getDescription() + "\n");
 195  154 return buffer.toString();
 196    }
 197   
 198    }