DefaultReference.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.bo.module;
017 
018 import org.qedeq.base.utility.EqualsUtility;
019 
020 
021 
022 
023 
024 /**
025  * A reference to a QEDEQ module or one of its parts.
026  *
027  @author  Michael Meyling
028  */
029 public class DefaultReference implements Reference {
030 
031     /** In this node the reference is in. */
032     private final KernelNodeBo nodeCurrent;
033 
034     /** To this QEDEQ module the reference points. */
035     private final KernelQedeqBo qedeqGoal;
036 
037     /** Label for the external QEDEQ module the reference points to. */
038     private final String qedeqGoalLabel;
039 
040     /** To this node the reference points to. */
041     private final KernelNodeBo nodeGoal;
042 
043     /** Label for the node the reference points to. */
044     private final String nodeGoalLabel;
045 
046     /** To this sub node label the reference points. */
047     private final String subLabel;
048 
049     /** To this proof line label the reference points to. */
050     private final String proofLineLabel;
051 
052     /**
053      * Constructor.
054      *
055      @param   nodeCurrent     In this node the reference is in.
056      @param   qedeqGoal       To this external QEDEQ module the reference points to.
057      @param   qedeqGoalLabel  Label for the external QEDEQ module the reference points to.
058      @param   nodeGoal        To this node the reference points to.
059      @param   nodeGoalLabel   Label for the node the reference points to.
060      @param   subLabel        To this sub node label the reference points.
061      @param   proofLineLabel  To this proof line label the reference points to.
062      */
063     public DefaultReference(final KernelNodeBo nodeCurrent,
064             final KernelQedeqBo qedeqGoal, final String qedeqGoalLabel,
065             final KernelNodeBo nodeGoal, final String nodeGoalLabel,
066             final String subLabel, final String proofLineLabel) {
067         this.nodeCurrent = nodeCurrent;
068         this.qedeqGoal = qedeqGoal;
069         this.qedeqGoalLabel = qedeqGoalLabel;
070         this.nodeGoal = nodeGoal;
071         this.nodeGoalLabel = nodeGoalLabel;
072         this.subLabel = subLabel;
073         this.proofLineLabel = proofLineLabel;
074     }
075 
076     public boolean isExternalModuleReference() {
077         return isExternal() && !isNodeReference();
078     }
079 
080     public KernelQedeqBo getExternalQedeq() {
081         return qedeqGoal;
082     }
083 
084     public String getExternalQedeqLabel() {
085         return qedeqGoalLabel;
086     }
087 
088     public KernelNodeBo getNode() {
089         return nodeGoal;
090     }
091 
092     public String getNodeLabel() {
093         return nodeGoalLabel;
094     }
095 
096     public String getProofLineLabel() {
097         return proofLineLabel;
098     }
099 
100     public String getSubLabel() {
101         return subLabel;
102     }
103 
104     public boolean isExternal() {
105         return qedeqGoalLabel != null && qedeqGoalLabel.length() 0;
106     }
107 
108     public boolean isNodeLocalReference() {
109         return EqualsUtility.equals(nodeGoal, nodeCurrent);
110     }
111 
112     public boolean isNodeReference() {
113         return nodeGoalLabel != null && nodeGoalLabel.length() 0;
114     }
115 
116     public boolean isSubReference() {
117         return subLabel != null && subLabel.length() 0;
118     }
119 
120     public boolean isProofLineReference() {
121         return proofLineLabel != null && proofLineLabel.length() 0;
122     }
123 
124 }