| 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.Node; |
| 21 | import org.qedeq.kernel.se.base.module.NodeType; |
| 22 | import org.qedeq.kernel.se.base.module.Subsection; |
| 23 | |
| 24 | |
| 25 | /** |
| 26 | * Special subsection of a QEDEQ file. |
| 27 | * |
| 28 | * @author Michael Meyling |
| 29 | */ |
| 30 | public class NodeVo implements Node { |
| 31 | |
| 32 | /** Module unique label for referencing. */ |
| 33 | private String id; |
| 34 | |
| 35 | /** Level of that node. Higher levels contain additional informations. */ |
| 36 | private String level; |
| 37 | |
| 38 | /** Node name. Could be used as an readable reference, e.g. "Axiom of Choice". */ |
| 39 | private LatexList name; |
| 40 | |
| 41 | /** Title of this subsection. */ |
| 42 | private LatexList title; |
| 43 | |
| 44 | /** Preceding LaTeX text. This text comes before a theorem, definition etc. |
| 45 | * but belongs to this node regards content. */ |
| 46 | private LatexList precedingText; |
| 47 | |
| 48 | /** Contains the concrete theorem or definition or else. */ |
| 49 | private NodeType nodeType; |
| 50 | |
| 51 | /** Succeeding LaTeX text. This text comes after a theorem, definition etc. |
| 52 | * but belongs to this node regards content. */ |
| 53 | private LatexList succeedingText; |
| 54 | |
| 55 | /** |
| 56 | * Constructs a new empty node. |
| 57 | */ |
| 58 | public NodeVo() { |
| 59 | // nothing to do |
| 60 | } |
| 61 | |
| 62 | public Node getNode() { |
| 63 | return this; |
| 64 | } |
| 65 | |
| 66 | public Subsection getSubsection() { |
| 67 | return null; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Set label for this node. Referencing must use this label. |
| 72 | * |
| 73 | * @param id Label for referencing. |
| 74 | */ |
| 75 | public final void setId(final String id) { |
| 76 | this.id = id; |
| 77 | } |
| 78 | |
| 79 | public final String getId() { |
| 80 | return id; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Set node level. |
| 85 | * |
| 86 | * @param level Level of this node. |
| 87 | */ |
| 88 | public final void setLevel(final String level) { |
| 89 | this.level = level; |
| 90 | } |
| 91 | |
| 92 | public final String getLevel() { |
| 93 | return level; |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Set node name. Could be used as an readable reference, e.g. "Axiom of Choice". |
| 98 | * |
| 99 | * @param name Name of this node. |
| 100 | */ |
| 101 | public final void setName(final LatexListVo name) { |
| 102 | this.name = name; |
| 103 | } |
| 104 | |
| 105 | public final LatexList getName() { |
| 106 | return name; |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * Set node title. |
| 111 | * |
| 112 | * @param title Title of node. |
| 113 | */ |
| 114 | public final void setTitle(final LatexListVo title) { |
| 115 | this.title = title; |
| 116 | } |
| 117 | |
| 118 | public final LatexList getTitle() { |
| 119 | return title; |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * Set preceding LaTeX text. This text comes before a theorem, definition etc. |
| 124 | * but belongs to this node regards content. |
| 125 | * |
| 126 | * @param precedingText Preceding LaTeX text. |
| 127 | */ |
| 128 | public final void setPrecedingText(final LatexListVo precedingText) { |
| 129 | this.precedingText = precedingText; |
| 130 | } |
| 131 | |
| 132 | public final LatexList getPrecedingText() { |
| 133 | return precedingText; |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * Set the concrete theorem or definition or else. |
| 138 | * |
| 139 | * @param nodeType An instance of {@link NodeType}. |
| 140 | */ |
| 141 | public final void setNodeType(final NodeType nodeType) { |
| 142 | this.nodeType = nodeType; |
| 143 | } |
| 144 | |
| 145 | public final NodeType getNodeType() { |
| 146 | return nodeType; |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * Set succeeding LaTeX text. This text comes after a theorem, definition etc. |
| 151 | * but belongs to this node regards content. |
| 152 | * |
| 153 | * @param succeedingText Succeeding LaTeX text. |
| 154 | */ |
| 155 | public final void setSucceedingText(final LatexListVo succeedingText) { |
| 156 | this.succeedingText = succeedingText; |
| 157 | } |
| 158 | |
| 159 | public final LatexList getSucceedingText() { |
| 160 | return succeedingText; |
| 161 | } |
| 162 | |
| 163 | public boolean equals(final Object obj) { |
| 164 | if (!(obj instanceof NodeVo)) { |
| 165 | return false; |
| 166 | } |
| 167 | final NodeVo node = (NodeVo) obj; |
| 168 | return EqualsUtility.equals(getId(), node.getId()) |
| 169 | && EqualsUtility.equals(getLevel(), node.getLevel()) |
| 170 | && EqualsUtility.equals(getName(), node.getName()) |
| 171 | && EqualsUtility.equals(getTitle(), node.getTitle()) |
| 172 | && EqualsUtility.equals(getPrecedingText(), node.getPrecedingText()) |
| 173 | && EqualsUtility.equals(getNodeType(), node.getNodeType()) |
| 174 | && EqualsUtility.equals(getSucceedingText(), node.getSucceedingText()); |
| 175 | } |
| 176 | |
| 177 | public int hashCode() { |
| 178 | return (getId() != null ? getId().hashCode() : 0) |
| 179 | ^ (getLevel() != null ? 1 ^ getLevel().hashCode() : 0) |
| 180 | ^ (getName() != null ? 2 ^ getName().hashCode() : 0) |
| 181 | ^ (getTitle() != null ? 3 ^ getTitle().hashCode() : 0) |
| 182 | ^ (getPrecedingText() != null ? 4 ^ getPrecedingText().hashCode() : 0) |
| 183 | ^ (getNodeType() != null ? 5 ^ getNodeType().hashCode() : 0) |
| 184 | ^ (getSucceedingText() != null ? 6 ^ getSucceedingText().hashCode() : 0); |
| 185 | } |
| 186 | |
| 187 | public String toString() { |
| 188 | final StringBuffer buffer = new StringBuffer(); |
| 189 | buffer.append("Node\t"); |
| 190 | buffer.append("Id: " + getId()); |
| 191 | buffer.append("\tLevel: " + getLevel() + "\n"); |
| 192 | buffer.append("Name: "); |
| 193 | buffer.append(getName() + "\n\n"); |
| 194 | buffer.append("Title: "); |
| 195 | buffer.append(getTitle() + "\n\n"); |
| 196 | buffer.append("Pre: "); |
| 197 | buffer.append(getPrecedingText() + "\n\n"); |
| 198 | buffer.append("NodeType: "); |
| 199 | buffer.append(getNodeType() + "\n\n"); |
| 200 | buffer.append("Suc: "); |
| 201 | buffer.append(getSucceedingText() + "\n\n"); |
| 202 | return buffer.toString(); |
| 203 | } |
| 204 | |
| 205 | } |