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.Chapter;
020 import org.qedeq.kernel.se.base.module.LatexList;
021 import org.qedeq.kernel.se.base.module.SectionList;
022
023
024 /**
025 * Chapter.
026 *
027 * @author Michael Meyling
028 */
029 public class ChapterVo implements Chapter {
030
031 /** Chapter title. */
032 private LatexList title;
033
034 /** No chapter number. */
035 private Boolean noNumber;
036
037 /** Chapter introduction. */
038 private LatexList introduction;
039
040 /** List of chapter sections. */
041 private SectionListVo sectionList;
042
043 /**
044 * Constructs a new chapter.
045 */
046 public ChapterVo() {
047 // nothing to do
048 }
049
050 /**
051 * Set automatic chapter number off or on.
052 *
053 * @param noNumber No chapter numbering?
054 */
055 public final void setNoNumber(final Boolean noNumber) {
056 this.noNumber = noNumber;
057 }
058
059 public final Boolean getNoNumber() {
060 return noNumber;
061 }
062
063 /**
064 * Set chapter title.
065 *
066 * @param title LaTeX list of chapter titles.
067 */
068 public final void setTitle(final LatexListVo title) {
069 this.title = title;
070 }
071
072 public final LatexList getTitle() {
073 return title;
074 }
075
076 /**
077 * Set chapter introduction text.
078 *
079 * @param introduction Introduction text.
080 */
081 public final void setIntroduction(final LatexListVo introduction) {
082 this.introduction = introduction;
083 }
084
085 public final LatexList getIntroduction() {
086 return introduction;
087 }
088
089 /**
090 * Set list of sections.
091 *
092 * @param sections Section list.
093 */
094 public final void setSectionList(final SectionListVo sections) {
095 this.sectionList = sections;
096 }
097
098 public final SectionList getSectionList() {
099 return sectionList;
100 }
101
102 /**
103 * Add section to list.
104 *
105 * @param section Section to add.
106 */
107 public final void addSection(final SectionVo section) {
108 if (sectionList == null) {
109 sectionList = new SectionListVo();
110 }
111 sectionList.add(section);
112 }
113
114 public boolean equals(final Object obj) {
115 if (!(obj instanceof ChapterVo)) {
116 return false;
117 }
118 final ChapterVo other = (ChapterVo) obj;
119 return EqualsUtility.equals(getNoNumber(), other.getNoNumber())
120 && EqualsUtility.equals(getTitle(), other.getTitle())
121 && EqualsUtility.equals(getIntroduction(), other.getIntroduction())
122 && EqualsUtility.equals(getSectionList(), other.getSectionList());
123 }
124
125 public int hashCode() {
126 return (getNoNumber() != null ? getNoNumber().hashCode() : 0)
127 ^ (getTitle() != null ? getTitle().hashCode() : 0)
128 ^ (getIntroduction() != null ? 1 ^ getIntroduction().hashCode() : 0)
129 ^ (getSectionList() != null ? 2 ^ getSectionList().hashCode() : 0);
130 }
131
132 public String toString() {
133 final StringBuffer buffer = new StringBuffer();
134 buffer.append("Chapter noNumber: " + getNoNumber() + "\n");
135 buffer.append("Chapter Title:\n");
136 buffer.append(getTitle() + "\n\n");
137 buffer.append("Introduction:\n");
138 buffer.append(getIntroduction() + "\n\n");
139 buffer.append(getSectionList() + "\n");
140 return buffer.toString();
141 }
142
143 }
|