NodeVo.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.Node;
021 import org.qedeq.kernel.se.base.module.NodeType;
022 
023 
024 /**
025  * Special subsection of a QEDEQ file.
026  *
027  @author  Michael Meyling
028  */
029 public class NodeVo implements Node {
030 
031     /** Module unique label for referencing. */
032     private String id;
033 
034     /** Level of that node. Higher levels contain additional informations. */
035     private String level;
036 
037     /** Node name. Could be used as an readable reference, e.g. "Axiom of Choice". */
038     private LatexList name;
039 
040     /** Title of this subsection. */
041     private LatexList title;
042 
043     /** Preceding LaTeX text. This text comes before a theorem, definition etc.
044      * but belongs to this node regards content. */
045     private LatexList precedingText;
046 
047     /** Contains the concrete theorem or definition or else. */
048     private NodeType nodeType;
049 
050     /** Succeeding LaTeX text. This text comes after a theorem, definition etc.
051      * but belongs to this node regards content. */
052     private LatexList succeedingText;
053 
054     /**
055      * Constructs a new empty node.
056      */
057     public NodeVo() {
058         // nothing to do
059     }
060 
061     /**
062      * Set label for this node. Referencing must use this label.
063      *
064      @param   id  Label for referencing.
065      */
066     public final void setId(final String id) {
067         this.id = id;
068     }
069 
070     public final String getId() {
071         return id;
072     }
073 
074     /**
075      * Set node level.
076      *
077      @param   level   Level of this node.
078      */
079     public final void setLevel(final String level) {
080         this.level = level;
081     }
082 
083     public final String getLevel() {
084         return level;
085     }
086 
087     /**
088      * Set node name. Could be used as an readable reference, e.g. "Axiom of Choice".
089      *
090      @param   name    Name of this node.
091      */
092     public final void setName(final LatexListVo name) {
093         this.name = name;
094     }
095 
096     public final LatexList getName() {
097         return name;
098     }
099 
100     /**
101      * Set node title.
102      *
103      @param   title   Title of node.
104      */
105     public final void setTitle(final LatexListVo title) {
106         this.title = title;
107     }
108 
109     public final LatexList getTitle() {
110         return title;
111     }
112 
113     /**
114      * Set preceding LaTeX text. This text comes before a theorem, definition etc.
115      * but belongs to this node regards content.
116      *
117      @param   precedingText   Preceding LaTeX text.
118      */
119     public final void setPrecedingText(final LatexListVo precedingText) {
120         this.precedingText = precedingText;
121     }
122 
123     public final LatexList getPrecedingText() {
124         return precedingText;
125     }
126 
127     /**
128      * Set the concrete theorem or definition or else.
129      *
130      @param   nodeType    An instance of {@link NodeType}.
131      */
132     public final void setNodeType(final NodeType nodeType) {
133         this.nodeType = nodeType;
134     }
135 
136     public final NodeType getNodeType() {
137         return nodeType;
138     }
139 
140     /**
141      * Set succeeding LaTeX text. This text comes after a theorem, definition etc.
142      * but belongs to this node regards content.
143      *
144      @param   succeedingText  Succeeding LaTeX text.
145      */
146     public final void setSucceedingText(final LatexListVo succeedingText) {
147         this.succeedingText = succeedingText;
148     }
149 
150     public final LatexList getSucceedingText() {
151         return succeedingText;
152     }
153 
154     public boolean equals(final Object obj) {
155         if (!(obj instanceof NodeVo)) {
156             return false;
157         }
158         final NodeVo node = (NodeVoobj;
159         return  EqualsUtility.equals(getId(), node.getId())
160             &&  EqualsUtility.equals(getLevel(), node.getLevel())
161             &&  EqualsUtility.equals(getName(), node.getName())
162             &&  EqualsUtility.equals(getTitle(), node.getTitle())
163             &&  EqualsUtility.equals(getPrecedingText(), node.getPrecedingText())
164             &&  EqualsUtility.equals(getNodeType(), node.getNodeType())
165             &&  EqualsUtility.equals(getSucceedingText(), node.getSucceedingText());
166     }
167 
168     public int hashCode() {
169         return (getId() != null ? getId().hashCode() 0)
170             (getLevel() != null ^ getLevel().hashCode() 0)
171             (getName() != null ^ getName().hashCode() 0)
172             (getTitle() != null ^ getTitle().hashCode() 0)
173             (getPrecedingText() != null ^ getPrecedingText().hashCode() 0)
174             (getNodeType() != null ^ getNodeType().hashCode() 0)
175             (getSucceedingText() != null ^ getSucceedingText().hashCode() 0);
176     }
177 
178     public String toString() {
179         final StringBuffer buffer = new StringBuffer();
180         buffer.append("Node\t");
181         buffer.append("Id: " + getId());
182         buffer.append("\tLevel: " + getLevel() "\n");
183         buffer.append("Name: ");
184         buffer.append(getName() "\n\n");
185         buffer.append("Title: ");
186         buffer.append(getTitle() "\n\n");
187         buffer.append("Pre: ");
188         buffer.append(getPrecedingText() "\n\n");
189         buffer.append("NodeType: ");
190         buffer.append(getNodeType() "\n\n");
191         buffer.append("Suc: ");
192         buffer.append(getSucceedingText() "\n\n");
193         return buffer.toString();
194     }
195 
196 }