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