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