NodeVo.java
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.NodeType;
022 import org.qedeq.kernel.se.base.module.Subsection;
023 
024 
025 /**
026  * Special subsection of a QEDEQ file.
027  *
028  @author  Michael Meyling
029  */
030 public class NodeVo implements Node {
031 
032     /** Module unique label for referencing. */
033     private String id;
034 
035     /** Level of that node. Higher levels contain additional informations. */
036     private String level;
037 
038     /** Node name. Could be used as an readable reference, e.g. "Axiom of Choice". */
039     private LatexList name;
040 
041     /** Title of this subsection. */
042     private LatexList title;
043 
044     /** Preceding LaTeX text. This text comes before a theorem, definition etc.
045      * but belongs to this node regards content. */
046     private LatexList precedingText;
047 
048     /** Contains the concrete theorem or definition or else. */
049     private NodeType nodeType;
050 
051     /** Succeeding LaTeX text. This text comes after a theorem, definition etc.
052      * but belongs to this node regards content. */
053     private LatexList succeedingText;
054 
055     /**
056      * Constructs a new empty node.
057      */
058     public NodeVo() {
059         // nothing to do
060     }
061 
062     public Node getNode() {
063         return this;
064     }
065 
066     public Subsection getSubsection() {
067         return null;
068     }
069 
070     /**
071      * Set label for this node. Referencing must use this label.
072      *
073      @param   id  Label for referencing.
074      */
075     public final void setId(final String id) {
076         this.id = id;
077     }
078 
079     public final String getId() {
080         return id;
081     }
082 
083     /**
084      * Set node level.
085      *
086      @param   level   Level of this node.
087      */
088     public final void setLevel(final String level) {
089         this.level = level;
090     }
091 
092     public final String getLevel() {
093         return level;
094     }
095 
096     /**
097      * Set node name. Could be used as an readable reference, e.g. "Axiom of Choice".
098      *
099      @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 = (NodeVoobj;
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 ^ getLevel().hashCode() 0)
180             (getName() != null ^ getName().hashCode() 0)
181             (getTitle() != null ^ getTitle().hashCode() 0)
182             (getPrecedingText() != null ^ getPrecedingText().hashCode() 0)
183             (getNodeType() != null ^ getNodeType().hashCode() 0)
184             (getSucceedingText() != null ^ 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 }