| 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.AuthorList; |
| 20 | import org.qedeq.kernel.se.base.module.Header; |
| 21 | import org.qedeq.kernel.se.base.module.ImportList; |
| 22 | import org.qedeq.kernel.se.base.module.LatexList; |
| 23 | import org.qedeq.kernel.se.base.module.Specification; |
| 24 | import org.qedeq.kernel.se.base.module.UsedByList; |
| 25 | |
| 26 | |
| 27 | /** |
| 28 | * Header of a qedeq file. The header specifies such things as the location of the file, |
| 29 | * the title and abstract of that module, imports and exports. |
| 30 | * |
| 31 | * @author Michael Meyling |
| 32 | */ |
| 33 | public class HeaderVo implements Header { |
| 34 | |
| 35 | /** Module specification. */ |
| 36 | private Specification specification; |
| 37 | |
| 38 | /** Module title. */ |
| 39 | private LatexList title; |
| 40 | |
| 41 | /** Module "abstract". */ |
| 42 | private LatexList summary; |
| 43 | |
| 44 | /** Author list. */ |
| 45 | private AuthorList authorList; |
| 46 | |
| 47 | /** List of imported modules. */ |
| 48 | private ImportList importList; |
| 49 | |
| 50 | /** List of modules that depend on current one. */ |
| 51 | private UsedByList usedByList; |
| 52 | |
| 53 | /** Email address of module administrator. */ |
| 54 | private String email; |
| 55 | |
| 56 | /** |
| 57 | * Constructs a new module header. |
| 58 | */ |
| 59 | public HeaderVo() { |
| 60 | // nothing to do |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Set module specification. |
| 65 | * @param specification Module specification. |
| 66 | */ |
| 67 | public final void setSpecification(final SpecificationVo specification) { |
| 68 | this.specification = specification; |
| 69 | } |
| 70 | |
| 71 | public final Specification getSpecification() { |
| 72 | return specification; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Set module title. |
| 77 | * |
| 78 | * @param title Module title texts. |
| 79 | */ |
| 80 | public final void setTitle(final LatexListVo title) { |
| 81 | this.title = title; |
| 82 | } |
| 83 | |
| 84 | public final LatexList getTitle() { |
| 85 | return title; |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Set module summary text. |
| 90 | * |
| 91 | * @param summary Module summary text. |
| 92 | */ |
| 93 | public final void setSummary(final LatexListVo summary) { |
| 94 | this.summary = summary; |
| 95 | } |
| 96 | |
| 97 | public final LatexList getSummary() { |
| 98 | return summary; |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Set list of authors of this module. |
| 103 | * |
| 104 | * @param authors Author list. |
| 105 | */ |
| 106 | public final void setAuthorList(final AuthorListVo authors) { |
| 107 | this.authorList = authors; |
| 108 | } |
| 109 | |
| 110 | public final AuthorList getAuthorList() { |
| 111 | return authorList; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Set list of imports needed for this module. |
| 116 | * |
| 117 | * @param imports Module import list. |
| 118 | */ |
| 119 | public final void setImportList(final ImportListVo imports) { |
| 120 | this.importList = imports; |
| 121 | } |
| 122 | |
| 123 | public final ImportList getImportList() { |
| 124 | return importList; |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Set list of known modules that need this module. |
| 129 | * |
| 130 | * @param usedby List of modules. |
| 131 | */ |
| 132 | public final void setUsedByList(final UsedByListVo usedby) { |
| 133 | this.usedByList = usedby; |
| 134 | } |
| 135 | |
| 136 | public final UsedByList getUsedByList() { |
| 137 | return usedByList; |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * Set email address of module administrator. |
| 142 | * |
| 143 | * @param email Email address. |
| 144 | */ |
| 145 | public final void setEmail(final String email) { |
| 146 | this.email = email; |
| 147 | } |
| 148 | |
| 149 | public final String getEmail() { |
| 150 | return email; |
| 151 | } |
| 152 | |
| 153 | public boolean equals(final Object obj) { |
| 154 | if (!(obj instanceof HeaderVo)) { |
| 155 | return false; |
| 156 | } |
| 157 | final HeaderVo other = (HeaderVo) obj; |
| 158 | return EqualsUtility.equals(getSpecification(), other.getSpecification()) |
| 159 | && EqualsUtility.equals(getTitle(), other.getTitle()) |
| 160 | && EqualsUtility.equals(getSummary(), other.getSummary()) |
| 161 | && EqualsUtility.equals(getAuthorList(), other.getAuthorList()) |
| 162 | && EqualsUtility.equals(getImportList(), other.getImportList()) |
| 163 | && EqualsUtility.equals(getUsedByList(), other.getUsedByList()) |
| 164 | && EqualsUtility.equals(getEmail(), other.getEmail()); |
| 165 | } |
| 166 | |
| 167 | public int hashCode() { |
| 168 | return (getSpecification() != null ? getSpecification().hashCode() : 0) |
| 169 | ^ (getTitle() != null ? 1 ^ getTitle().hashCode() : 0) |
| 170 | ^ (getSummary() != null ? 2 ^ getSummary().hashCode() : 0) |
| 171 | ^ (getAuthorList() != null ? 3 ^ getAuthorList().hashCode() : 0) |
| 172 | ^ (getImportList() != null ? 4 ^ getImportList().hashCode() : 0) |
| 173 | ^ (getUsedByList() != null ? 5 ^ getUsedByList().hashCode() : 0) |
| 174 | ^ (getEmail() != null ? 6 ^ getEmail().hashCode() : 0); |
| 175 | } |
| 176 | |
| 177 | public String toString() { |
| 178 | final StringBuffer buffer = new StringBuffer("Header\n"); |
| 179 | buffer.append(getSpecification() + "\n"); |
| 180 | buffer.append("Title: "); |
| 181 | buffer.append(getTitle() + "\n\n"); |
| 182 | buffer.append("Abstract: "); |
| 183 | buffer.append(getSummary() + "\n\n"); |
| 184 | buffer.append(getAuthorList() + "\n"); |
| 185 | buffer.append(getImportList() + "\n"); |
| 186 | buffer.append(getUsedByList() + "\n"); |
| 187 | if (getEmail() != null) { |
| 188 | buffer.append("\nModule email: <" + getEmail() + ">"); |
| 189 | } |
| 190 | return buffer.toString(); |
| 191 | } |
| 192 | |
| 193 | } |