View Javadoc

1   /* This file is part of the project "Hilbert II" - http://www.qedeq.org" target="alexandria_uri">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.Node;
21  import org.qedeq.kernel.se.base.module.Subsection;
22  
23  
24  /**
25   * Subsection of a qedeq file.
26   *
27   * @author  Michael Meyling
28   */
29  public class SubsectionVo implements Subsection {
30  
31      /** Label for referencing. */
32      private String id;
33  
34      /** Level of that subsection. Higher levels contain additional informations. */
35      private String level;
36  
37      /** Title of this subsection. */
38      private LatexList title;
39  
40      /** LaTeX text.  */
41      private LatexList latex;
42  
43      /**
44       * Constructs a new empty subsection.
45       */
46      public SubsectionVo() {
47          // nothing to do
48      }
49  
50      public Node getNode() {
51          return null;
52      }
53  
54      public Subsection getSubsection() {
55          return this;
56      }
57  
58      /**
59       * Set label for this subsection.
60       *
61       * @param   label   Label for referencing.
62       */
63      public final void setId(final String label) {
64          this.id = label;
65      }
66  
67      public final String getId() {
68          return id;
69      }
70  
71      /**
72       * Set level for this section. Higher levels contain additional informations
73       *
74       * @param   level   Level of that subsection.
75       */
76      public final void setLevel(final String level) {
77          this.level = level;
78      }
79  
80      public final String getLevel() {
81          return level;
82      }
83  
84      /**
85       * Set title of this subsection.
86       *
87       * @param   title   Subsection title.
88       */
89      public final void setTitle(final LatexListVo title) {
90          this.title = title;
91      }
92  
93      public final LatexList getTitle() {
94          return title;
95      }
96  
97      /**
98       * Set LaTeX text for this subsection.
99       *
100      * @param   latexText   LaTeX text.
101      */
102     public final void setLatex(final LatexListVo latexText) {
103         this.latex = latexText;
104     }
105 
106     public final LatexList getLatex() {
107         return latex;
108     }
109 
110     public boolean equals(final Object obj) {
111         if (!(obj instanceof SubsectionVo)) {
112             return false;
113         }
114         final SubsectionVo subsection = (SubsectionVo) obj;
115         return  EqualsUtility.equals(getId(), subsection.getId())
116             &&  EqualsUtility.equals(getLevel(), subsection.getLevel())
117             &&  EqualsUtility.equals(getTitle(), subsection.getTitle())
118             &&  EqualsUtility.equals(getLatex(), subsection.getLatex());
119     }
120 
121     public int hashCode() {
122         return (getId() != null ? getId().hashCode() : 0)
123             ^ (getLevel() != null ? 1 ^ getLevel().hashCode() : 0)
124             ^ (getTitle() != null ? 2 ^ getTitle().hashCode() : 0)
125             ^ (getLatex() != null ? 3 ^ getLatex().hashCode() : 0);
126     }
127 
128     public String toString() {
129         final StringBuffer buffer = new StringBuffer();
130         buffer.append("Subsection\t");
131         buffer.append("Label: " + getId());
132         buffer.append("\tLevel: " + getLevel() + "\n");
133         buffer.append("Title: ");
134         buffer.append(getTitle() + "\n\n");
135         buffer.append("Pre: ");
136         buffer.append(getLatex() + "\n\n");
137         return buffer.toString();
138     }
139 
140 }