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