001 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
002 *
003 * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
004 *
005 * "Hilbert II" is free software; you can redistribute
006 * it and/or modify it under the terms of the GNU General Public
007 * License as published by the Free Software Foundation; either
008 * version 2 of the License, or (at your option) any later version.
009 *
010 * This program is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013 * GNU General Public License for more details.
014 */
015
016 package org.qedeq.kernel.se.dto.module;
017
018 import org.qedeq.base.utility.EqualsUtility;
019 import org.qedeq.kernel.se.base.module.ChapterList;
020 import org.qedeq.kernel.se.base.module.Header;
021 import org.qedeq.kernel.se.base.module.LiteratureItemList;
022 import org.qedeq.kernel.se.base.module.Qedeq;
023
024
025 /**
026 * A complete QEDEQ module. This is the root value object.
027 *
028 * @author Michael Meyling
029 */
030 public class QedeqVo implements Qedeq {
031
032 /** Header of module. */
033 private Header header;
034
035 /** All module chapters. */
036 private ChapterListVo chapterList;
037
038 /** Bibliography. */
039 private LiteratureItemList literatureItemList;
040
041 /**
042 * Constructs a new empty qedeq module.
043 */
044 public QedeqVo() {
045 // nothing to do
046 }
047
048 /**
049 * Set header for this module.
050 *
051 * @param header Module header.
052 */
053 public final void setHeader(final HeaderVo header) {
054 this.header = header;
055 }
056
057 public final Header getHeader() {
058 return header;
059 }
060
061 /**
062 * Set chapter list of this module.
063 *
064 * @param chapters Chapter list.
065 */
066 public final void setChapterList(final ChapterListVo chapters) {
067 this.chapterList = chapters;
068 }
069
070 public final ChapterList getChapterList() {
071 return chapterList;
072 }
073
074 /**
075 * Add chapter to this module.
076 *
077 * @param chapter Chapter to add.
078 */
079 public final void addChapter(final ChapterVo chapter) {
080 if (chapterList == null) {
081 chapterList = new ChapterListVo();
082 }
083 chapterList.add(chapter);
084 }
085
086 public LiteratureItemList getLiteratureItemList() {
087 return literatureItemList;
088 }
089
090 /**
091 * Set bibliography.
092 *
093 * @param literatureItemList Bibliography.
094 */
095 public void setLiteratureItemList(final LiteratureItemListVo literatureItemList) {
096 this.literatureItemList = literatureItemList;
097 }
098
099 public boolean equals(final Object obj) {
100 if (!(obj instanceof QedeqVo)) {
101 return false;
102 }
103 final QedeqVo other = (QedeqVo) obj;
104 return EqualsUtility.equals(getHeader(), other.getHeader())
105 && EqualsUtility.equals(getChapterList(), other.getChapterList())
106 && EqualsUtility.equals(getLiteratureItemList(), other.getLiteratureItemList());
107 }
108
109 public int hashCode() {
110 return (getHeader() != null ? getHeader().hashCode() : 0)
111 ^ (getChapterList() != null ? 1 ^ getChapterList().hashCode() : 0)
112 ^ (getLiteratureItemList() != null ? 2 ^ getLiteratureItemList().hashCode() : 0);
113 }
114
115 public String toString() {
116 final StringBuffer buffer = new StringBuffer();
117 buffer.append(getHeader() + "\n\n");
118 buffer.append(getChapterList() + "\n\n");
119 buffer.append(getLiteratureItemList());
120 return buffer.toString();
121 }
122
123 }
|