Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: So Feb 25 2007 22:22:30 CET
file stats: LOC: 176   Methods: 15
NCLOC: 78   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
QedeqBo.java 100% 96% 93,3% 96%
coverage coverage
 1    /* $Id: QedeqBo.java,v 1.9 2007/02/25 20:05:33 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.bo.module;
 19   
 20    import org.qedeq.kernel.base.module.ChapterList;
 21    import org.qedeq.kernel.base.module.Header;
 22    import org.qedeq.kernel.base.module.LiteratureItemList;
 23    import org.qedeq.kernel.base.module.Qedeq;
 24    import org.qedeq.kernel.dto.module.ChapterListVo;
 25    import org.qedeq.kernel.dto.module.ChapterVo;
 26    import org.qedeq.kernel.dto.module.HeaderVo;
 27    import org.qedeq.kernel.dto.module.LiteratureItemListVo;
 28    import org.qedeq.kernel.utility.EqualsUtility;
 29   
 30   
 31    /**
 32    * A complete QEDEQ module. This is the root business object.
 33    *
 34    * TODO mime 20070131: shouldn't be a globalContext also an attribute of this class?
 35    *
 36    * @version $Revision: 1.9 $
 37    * @author Michael Meyling
 38    */
 39    public final class QedeqBo implements Qedeq {
 40   
 41    /** Header of module. */
 42    private HeaderVo header;
 43   
 44    /** All module chapters. */
 45    private ChapterListVo chapterList;
 46   
 47    /** All module labels and their business objects. */
 48    private final ModuleLabels moduleLabels;
 49   
 50    /** Bibliography. */
 51    private LiteratureItemList literatureItemList;
 52   
 53    /** Module state. */
 54    private QedeqBoState state;
 55   
 56    /**
 57    * Constructs a new empty qedeq module.
 58    */
 59  61 public QedeqBo() {
 60  61 moduleLabels = new ModuleLabels();
 61  61 state = QedeqBoState.STATE_CREATING;
 62    }
 63   
 64    /**
 65    * Set header of module.
 66    *
 67    * @param header Module header.
 68    */
 69  31 public final void setHeader(final HeaderVo header) {
 70  31 this.header = header;
 71    }
 72   
 73  259 public final Header getHeader() {
 74  259 return header;
 75    }
 76   
 77    /**
 78    * Set chapter list of this module.
 79    *
 80    * @param chapters Chapter list.
 81    */
 82  29 public final void setChapterList(final ChapterListVo chapters) {
 83  29 this.chapterList = chapters;
 84    }
 85   
 86  232 public final ChapterList getChapterList() {
 87  232 return chapterList;
 88    }
 89   
 90    /**
 91    * Add chapter to this module.
 92    *
 93    * @param chapter Chapter to add.
 94    */
 95  7 public final void addChapter(final ChapterVo chapter) {
 96  7 if (chapterList == null) {
 97  4 chapterList = new ChapterListVo();
 98    }
 99  7 chapterList.add(chapter);
 100    }
 101   
 102    /**
 103    * Set bibliography.
 104    *
 105    * @param literatureItemList Bibliography.
 106    */
 107  17 public void setLiteratureItemList(final LiteratureItemListVo literatureItemList) {
 108  17 this.literatureItemList = literatureItemList;
 109    }
 110   
 111  189 public LiteratureItemList getLiteratureItemList() {
 112  189 return literatureItemList;
 113    }
 114   
 115  61 public boolean equals(final Object obj) {
 116  61 if (!(obj instanceof QedeqBo)) {
 117  6 return false;
 118    }
 119  55 final QedeqBo other = (QedeqBo) obj;
 120  55 return EqualsUtility.equals(getHeader(), other.getHeader())
 121    && EqualsUtility.equals(getChapterList(), other.getChapterList())
 122    && EqualsUtility.equals(getLiteratureItemList(), other.getLiteratureItemList());
 123    }
 124   
 125  34 public int hashCode() {
 126  34 return (getHeader() != null ? getHeader().hashCode() : 0)
 127  34 ^ (getChapterList() != null ? 1 ^ getChapterList().hashCode() : 0)
 128  34 ^ (getLiteratureItemList() != null ? 2 ^ getLiteratureItemList().hashCode() : 0);
 129    }
 130   
 131  37 public String toString() {
 132  37 final StringBuffer buffer = new StringBuffer();
 133  37 buffer.append(getHeader() + "\n\n");
 134  37 buffer.append(getChapterList() + "\n\n");
 135  37 buffer.append(getLiteratureItemList());
 136  37 return buffer.toString();
 137    }
 138   
 139    /**
 140    * Get module label associations for this module.
 141    *
 142    * @return Label associations.
 143    */
 144  438 public final ModuleLabels getModuleLabels() {
 145  438 return moduleLabels;
 146    }
 147   
 148    /**
 149    * Get module state.
 150    *
 151    * @return Module state.
 152    */
 153  1 public final QedeqBoState getState() {
 154  1 return state;
 155    }
 156   
 157    /**
 158    * Set module state.
 159    *
 160    * @param state Module state to set.
 161    */
 162  5 public final void setState(final QedeqBoState state) {
 163  5 this.state = state;
 164    }
 165   
 166    /**
 167    * Get physical addresses of this module.
 168    *
 169    * @return Module file access information.
 170    */
 171  0 public final ModuleAddress getModuleAddress() {
 172    // TODO mime 20051005: implementation
 173  0 return null;
 174    }
 175   
 176    }