Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Sa Okt 21 2006 08:24:31 CEST
file stats: LOC: 148   Methods: 13
NCLOC: 70   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ChapterVo.java 100% 100% 100% 100%
coverage
 1    /* $Id: ChapterVo.java,v 1.6 2006/10/20 20:23:01 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.dto.module;
 19   
 20    import org.qedeq.kernel.base.module.Chapter;
 21    import org.qedeq.kernel.base.module.LatexList;
 22    import org.qedeq.kernel.base.module.Section;
 23    import org.qedeq.kernel.base.module.SectionList;
 24    import org.qedeq.kernel.utility.EqualsUtility;
 25   
 26   
 27    /**
 28    * Chapter.
 29    *
 30    * @version $Revision: 1.6 $
 31    * @author Michael Meyling
 32    */
 33    public final class ChapterVo implements Chapter {
 34   
 35    /** Chapter title. */
 36    private LatexList title;
 37   
 38    /** No chapter number. */
 39    private Boolean noNumber;
 40   
 41    /** Chapter introduction. */
 42    private LatexList introduction;
 43   
 44    /** List of chapter sections. */
 45    private SectionListVo sectionList;
 46   
 47    /**
 48    * Constructs a new chapter.
 49    */
 50  151 public ChapterVo() {
 51    // nothing to do
 52    }
 53   
 54    /**
 55    * Set automatic chapter number off or on.
 56    *
 57    * @param noNumber No chapter numbering?
 58    */
 59  126 public final void setNoNumber(final Boolean noNumber) {
 60  126 this.noNumber = noNumber;
 61    }
 62   
 63  582 public final Boolean getNoNumber() {
 64  582 return noNumber;
 65    }
 66   
 67    /**
 68    * Set chapter title.
 69    *
 70    * @param title LaTeX list of chapter titles.
 71    */
 72  126 public final void setTitle(final LatexList title) {
 73  126 this.title = title;
 74    }
 75   
 76  669 public final LatexList getTitle() {
 77  669 return title;
 78    }
 79   
 80    /**
 81    * Set chapter introduction text.
 82    *
 83    * @param introduction Introduction text.
 84    */
 85  126 public final void setIntroduction(final LatexList introduction) {
 86  126 this.introduction = introduction;
 87    }
 88   
 89  645 public final LatexList getIntroduction() {
 90  645 return introduction;
 91    }
 92   
 93    /**
 94    * Set list of sections.
 95    *
 96    * @param sections Section list.
 97    */
 98  45 public final void setSectionList(final SectionListVo sections) {
 99  45 this.sectionList = sections;
 100    }
 101   
 102  2527 public final SectionList getSectionList() {
 103  2527 return sectionList;
 104    }
 105   
 106    /**
 107    * Add section to list.
 108    *
 109    * @param section Section to add.
 110    */
 111  136 public final void addSection(final Section section) {
 112  136 if (sectionList == null) { // TODO mime 20050316: creates additional dependency.
 113    // At other locations only an interface is referenced!
 114  53 sectionList = new SectionListVo();
 115    }
 116  136 sectionList.add(section);
 117    }
 118   
 119  117 public boolean equals(final Object obj) {
 120  117 if (!(obj instanceof ChapterVo)) {
 121  9 return false;
 122    }
 123  108 final ChapterVo other = (ChapterVo) obj;
 124  108 return EqualsUtility.equals(getNoNumber(), other.getNoNumber())
 125    && EqualsUtility.equals(getTitle(), other.getTitle())
 126    && EqualsUtility.equals(getIntroduction(), other.getIntroduction())
 127    && EqualsUtility.equals(getSectionList(), other.getSectionList());
 128    }
 129   
 130  104 public int hashCode() {
 131  104 return (getNoNumber() != null ? getNoNumber().hashCode() : 0)
 132  104 ^ (getTitle() != null ? getTitle().hashCode() : 0)
 133  104 ^ (getIntroduction() != null ? 1 ^ getIntroduction().hashCode() : 0)
 134  104 ^ (getSectionList() != null ? 2 ^ getSectionList().hashCode() : 0);
 135    }
 136   
 137  79 public String toString() {
 138  79 final StringBuffer buffer = new StringBuffer();
 139  79 buffer.append("Chapter noNumber: " + getNoNumber() + "\n");
 140  79 buffer.append("Chapter Title:\n");
 141  79 buffer.append(getTitle() + "\n\n");
 142  79 buffer.append("Introduction:\n");
 143  79 buffer.append(getIntroduction() + "\n\n");
 144  79 buffer.append(getSectionList() + "\n");
 145  79 return buffer.toString();
 146    }
 147   
 148    }