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.LatexList;
020 import org.qedeq.kernel.se.base.module.Node;
021 import org.qedeq.kernel.se.base.module.Subsection;
022
023
024 /**
025 * Subsection of a qedeq file.
026 *
027 * @author Michael Meyling
028 */
029 public class SubsectionVo implements Subsection {
030
031 /** Label for referencing. */
032 private String id;
033
034 /** Level of that subsection. Higher levels contain additional informations. */
035 private String level;
036
037 /** Title of this subsection. */
038 private LatexList title;
039
040 /** LaTeX text. */
041 private LatexList latex;
042
043 /**
044 * Constructs a new empty subsection.
045 */
046 public SubsectionVo() {
047 // nothing to do
048 }
049
050 public Node getNode() {
051 return null;
052 }
053
054 public Subsection getSubsection() {
055 return this;
056 }
057
058 /**
059 * Set label for this subsection.
060 *
061 * @param label Label for referencing.
062 */
063 public final void setId(final String label) {
064 this.id = label;
065 }
066
067 public final String getId() {
068 return id;
069 }
070
071 /**
072 * Set level for this section. Higher levels contain additional informations
073 *
074 * @param level Level of that subsection.
075 */
076 public final void setLevel(final String level) {
077 this.level = level;
078 }
079
080 public final String getLevel() {
081 return level;
082 }
083
084 /**
085 * Set title of this subsection.
086 *
087 * @param title Subsection title.
088 */
089 public final void setTitle(final LatexListVo title) {
090 this.title = title;
091 }
092
093 public final LatexList getTitle() {
094 return title;
095 }
096
097 /**
098 * Set LaTeX text for this subsection.
099 *
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 }
|