| 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.Latex; |
| 20 | |
| 21 | |
| 22 | /** |
| 23 | * LaTeX text part. |
| 24 | * |
| 25 | * @author Michael Meyling |
| 26 | */ |
| 27 | public class LatexVo implements Latex { |
| 28 | |
| 29 | /** Text language. */ |
| 30 | private String language; |
| 31 | |
| 32 | /** LaTeX text. */ |
| 33 | private String latex; |
| 34 | |
| 35 | /** |
| 36 | * Constructs a LaTeX text part. |
| 37 | * |
| 38 | * @param language Language of this part. |
| 39 | * @param latex LaTeX text. |
| 40 | */ |
| 41 | public LatexVo(final String language, final String latex) { |
| 42 | this.language = language; |
| 43 | this.latex = latex; |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Constructs an empty LaTeX text part. |
| 48 | */ |
| 49 | public LatexVo() { |
| 50 | // nothing to do |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Set text language. Examples are <code>en</code>, <code>de</code>. |
| 55 | * |
| 56 | * @param language Language. |
| 57 | */ |
| 58 | public final void setLanguage(final String language) { |
| 59 | this.language = language; |
| 60 | } |
| 61 | |
| 62 | public final String getLanguage() { |
| 63 | return language; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Set LaTeX text. |
| 68 | * |
| 69 | * @param latex LaTeX text. |
| 70 | */ |
| 71 | public final void setLatex(final String latex) { |
| 72 | this.latex = latex; |
| 73 | } |
| 74 | |
| 75 | public final String getLatex() { |
| 76 | return latex; |
| 77 | } |
| 78 | |
| 79 | public boolean equals(final Object obj) { |
| 80 | if (!(obj instanceof LatexVo)) { |
| 81 | return false; |
| 82 | } |
| 83 | final LatexVo other = (LatexVo) obj; |
| 84 | return EqualsUtility.equals(getLanguage(), other.getLanguage()) |
| 85 | && EqualsUtility.equals(getLatex(), other.getLatex()); |
| 86 | } |
| 87 | |
| 88 | public int hashCode() { |
| 89 | return (getLanguage() != null ? getLanguage().hashCode() : 0) |
| 90 | ^ (getLatex() != null ? 1 ^ getLatex().hashCode() : 0); |
| 91 | } |
| 92 | |
| 93 | public String toString() { |
| 94 | return "\"" + getLanguage() + "\":" + getLatex(); |
| 95 | } |
| 96 | |
| 97 | } |