1 | /* This file is part of the project "Hilbert II" - http://www.qedeq.org |
2 | * |
3 | * Copyright 2000-2014, Michael Meyling <mime@qedeq.org>. |
4 | * |
5 | * "Hilbert II" is free software; you can redistribute |
6 | * it and/or modify it under the terms of the GNU General Public |
7 | * License as published by the Free Software Foundation; either |
8 | * version 2 of the License, or (at your option) any later version. |
9 | * |
10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. |
14 | */ |
15 | |
16 | package org.qedeq.kernel.se.dto.module; |
17 | |
18 | import org.qedeq.base.utility.EqualsUtility; |
19 | import org.qedeq.kernel.se.base.module.LatexList; |
20 | import org.qedeq.kernel.se.base.module.Section; |
21 | import org.qedeq.kernel.se.base.module.SubsectionList; |
22 | |
23 | |
24 | /** |
25 | * Section of a QEDEQ file. |
26 | * |
27 | * @author Michael Meyling |
28 | */ |
29 | public class SectionVo implements Section { |
30 | |
31 | /** No section number. */ |
32 | private Boolean noNumber; |
33 | |
34 | /** Section title. */ |
35 | private LatexList title; |
36 | |
37 | /** Section introduction. */ |
38 | private LatexList introduction; |
39 | |
40 | /** All subsections of this section.*/ |
41 | private SubsectionList subsectionList; |
42 | |
43 | /** |
44 | * Constructs a new section. |
45 | */ |
46 | public SectionVo() { |
47 | // nothing to do |
48 | } |
49 | |
50 | /** |
51 | * Set no auto numbering for this section. |
52 | * |
53 | * @param noNumber Should this section be not numbered? |
54 | */ |
55 | public final void setNoNumber(final Boolean noNumber) { |
56 | this.noNumber = noNumber; |
57 | } |
58 | |
59 | public final Boolean getNoNumber() { |
60 | return noNumber; |
61 | } |
62 | |
63 | /** |
64 | * Set section title. |
65 | * |
66 | * @param title Section title. |
67 | */ |
68 | public final void setTitle(final LatexListVo title) { |
69 | this.title = title; |
70 | } |
71 | |
72 | public final LatexList getTitle() { |
73 | return title; |
74 | } |
75 | |
76 | /** |
77 | * Set LaTeX introduction text. |
78 | * |
79 | * @param introduction Introduction text. |
80 | */ |
81 | public final void setIntroduction(final LatexListVo introduction) { |
82 | this.introduction = introduction; |
83 | } |
84 | |
85 | public final LatexList getIntroduction() { |
86 | return introduction; |
87 | } |
88 | |
89 | /** |
90 | * Set list of subsections of this section. |
91 | * |
92 | * @param subsections List of subsections. |
93 | */ |
94 | public final void setSubsectionList(final SubsectionListVo subsections) { |
95 | this.subsectionList = subsections; |
96 | } |
97 | |
98 | public final SubsectionList getSubsectionList() { |
99 | return subsectionList; |
100 | } |
101 | |
102 | public boolean equals(final Object obj) { |
103 | if (!(obj instanceof SectionVo)) { |
104 | return false; |
105 | } |
106 | final SectionVo other = (SectionVo) obj; |
107 | return EqualsUtility.equals(getNoNumber(), other.getNoNumber()) |
108 | && EqualsUtility.equals(getTitle(), other.getTitle()) |
109 | && EqualsUtility.equals(getIntroduction(), other.getIntroduction()) |
110 | && EqualsUtility.equals(getSubsectionList(), other.getSubsectionList()); |
111 | } |
112 | |
113 | public int hashCode() { |
114 | return (getNoNumber() != null ? getNoNumber().hashCode() : 0) |
115 | ^ (getTitle() != null ? 1 ^ getTitle().hashCode() : 0) |
116 | ^ (getIntroduction() != null ? 2 ^ getIntroduction().hashCode() : 0) |
117 | ^ (getSubsectionList() != null ? 3 ^ getSubsectionList().hashCode() : 0); |
118 | } |
119 | |
120 | public String toString() { |
121 | final StringBuffer buffer = new StringBuffer(); |
122 | buffer.append("Section noNumbering: " + noNumber + "\n"); |
123 | buffer.append("Section Title: \n"); |
124 | buffer.append(getTitle() + "\n\n"); |
125 | buffer.append("Introduction: "); |
126 | buffer.append(getIntroduction() + "\n\n"); |
127 | buffer.append(getSubsectionList() + "\n"); |
128 | return buffer.toString(); |
129 | } |
130 | |
131 | } |