| 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.bo.module; |
| 17 | |
| 18 | import org.qedeq.base.utility.EqualsUtility; |
| 19 | |
| 20 | |
| 21 | /** |
| 22 | * A reference to a QEDEQ module or one of its parts. |
| 23 | * |
| 24 | * @author Michael Meyling |
| 25 | */ |
| 26 | public class DefaultReference implements Reference { |
| 27 | |
| 28 | /** In this node the reference is in. */ |
| 29 | private final KernelNodeBo nodeCurrent; |
| 30 | |
| 31 | /** To this QEDEQ module the reference points. */ |
| 32 | private final KernelQedeqBo qedeqGoal; |
| 33 | |
| 34 | /** Label for the external QEDEQ module the reference points to. */ |
| 35 | private final String qedeqGoalLabel; |
| 36 | |
| 37 | /** To this node the reference points to. */ |
| 38 | private final KernelNodeBo nodeGoal; |
| 39 | |
| 40 | /** Label for the node the reference points to. */ |
| 41 | private final String nodeGoalLabel; |
| 42 | |
| 43 | /** To this sub node label the reference points. */ |
| 44 | private final String subLabel; |
| 45 | |
| 46 | /** To this proof line label the reference points to. */ |
| 47 | private final String proofLineLabel; |
| 48 | |
| 49 | /** |
| 50 | * Constructor. |
| 51 | * |
| 52 | * @param nodeCurrent In this node the reference is in. |
| 53 | * @param qedeqGoal To this external QEDEQ module the reference points to. |
| 54 | * @param qedeqGoalLabel Label for the external QEDEQ module the reference points to. |
| 55 | * @param nodeGoal To this node the reference points to. |
| 56 | * @param nodeGoalLabel Label for the node the reference points to. |
| 57 | * @param subLabel To this sub node label the reference points. |
| 58 | * @param proofLineLabel To this proof line label the reference points to. |
| 59 | */ |
| 60 | public DefaultReference(final KernelNodeBo nodeCurrent, |
| 61 | final KernelQedeqBo qedeqGoal, final String qedeqGoalLabel, |
| 62 | final KernelNodeBo nodeGoal, final String nodeGoalLabel, |
| 63 | final String subLabel, final String proofLineLabel) { |
| 64 | this.nodeCurrent = nodeCurrent; |
| 65 | this.qedeqGoal = qedeqGoal; |
| 66 | this.qedeqGoalLabel = qedeqGoalLabel; |
| 67 | this.nodeGoal = nodeGoal; |
| 68 | this.nodeGoalLabel = nodeGoalLabel; |
| 69 | this.subLabel = subLabel; |
| 70 | this.proofLineLabel = proofLineLabel; |
| 71 | } |
| 72 | |
| 73 | public boolean isExternalModuleReference() { |
| 74 | return isExternal() && !isNodeReference(); |
| 75 | } |
| 76 | |
| 77 | public KernelQedeqBo getExternalQedeq() { |
| 78 | return qedeqGoal; |
| 79 | } |
| 80 | |
| 81 | public String getExternalQedeqLabel() { |
| 82 | return qedeqGoalLabel; |
| 83 | } |
| 84 | |
| 85 | public KernelNodeBo getNode() { |
| 86 | return nodeGoal; |
| 87 | } |
| 88 | |
| 89 | public String getNodeLabel() { |
| 90 | return nodeGoalLabel; |
| 91 | } |
| 92 | |
| 93 | public String getProofLineLabel() { |
| 94 | return proofLineLabel; |
| 95 | } |
| 96 | |
| 97 | public String getSubLabel() { |
| 98 | return subLabel; |
| 99 | } |
| 100 | |
| 101 | public boolean isExternal() { |
| 102 | return qedeqGoalLabel != null && qedeqGoalLabel.length() > 0; |
| 103 | } |
| 104 | |
| 105 | public boolean isNodeLocalReference() { |
| 106 | return EqualsUtility.equals(nodeGoal, nodeCurrent); |
| 107 | } |
| 108 | |
| 109 | public boolean isNodeReference() { |
| 110 | return nodeGoalLabel != null && nodeGoalLabel.length() > 0; |
| 111 | } |
| 112 | |
| 113 | public boolean isSubReference() { |
| 114 | return subLabel != null && subLabel.length() > 0; |
| 115 | } |
| 116 | |
| 117 | public boolean isProofLineReference() { |
| 118 | return proofLineLabel != null && proofLineLabel.length() > 0; |
| 119 | } |
| 120 | |
| 121 | } |