SectionVo.java
001 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
002  *
003  * Copyright 2000-2011,  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.LatexList;
020 import org.qedeq.kernel.se.base.module.Section;
021 import org.qedeq.kernel.se.base.module.SubsectionList;
022 
023 
024 /**
025  * Section of a QEDEQ file.
026  *
027  @author  Michael Meyling
028  */
029 public class SectionVo implements Section {
030 
031     /** No section number. */
032     private Boolean noNumber;
033 
034     /** Section title. */
035     private LatexList title;
036 
037     /** Section introduction. */
038     private LatexList introduction;
039 
040     /** All subsections of this section.*/
041     private SubsectionList subsectionList;
042 
043     /**
044      * Constructs a new section.
045      */
046     public SectionVo() {
047         // nothing to do
048     }
049 
050     /**
051      * Set no auto numbering for this section.
052      *
053      @param   noNumber    Should this section be not numbered?
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 section title.
065      *
066      @param   title   Section title.
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 LaTeX 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 subsections of this section.
091      *
092      @param   subsections List of subsections.
093      */
094     public final void setSubsectionList(final SubsectionListVo subsections) {
095         this.subsectionList = subsections;
096     }
097 
098     public final SubsectionList getSubsectionList() {
099         return subsectionList;
100     }
101 
102     public boolean equals(final Object obj) {
103         if (!(obj instanceof SectionVo)) {
104             return false;
105         }
106         final SectionVo other = (SectionVoobj;
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 ^ getTitle().hashCode() 0)
116             (getIntroduction() != null ^ getIntroduction().hashCode() 0)
117             (getSubsectionList() != null ^ 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 }