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