ProofLineData.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.bo.service.unicode;
017 
018 
019 /**
020  * Contains printing data for a formal proof line.
021  *
022  @author  Michael Meyling
023  */
024 public class ProofLineData {
025 
026     /** Current Label of formal proof line. */
027     private String lineLabel;
028 
029     /** String representation of formal proof line formula. */
030     private String[] formula;
031 
032     /** String representation of formal proof line reason. */
033     private String[] reason;
034 
035     /**
036      * Constructs empty container.
037      */
038     public ProofLineData() {
039         init();
040     }
041 
042     /**
043      * Construct new proof line data.
044      *
045      @param   lineLabel   Proof line label.
046      @param   formula     Formula strings.
047      @param   reason      Reason strings.
048      */
049     public ProofLineData(final String lineLabel, final String[] formula, final String[] reason) {
050         this.lineLabel = lineLabel;
051         this.formula = formula;
052         this.reason = reason;
053     }
054 
055     /**
056      * Copy constructor.
057      *
058      @param   lineData    Existing object.
059      */
060     public ProofLineData(final ProofLineData lineData) {
061         this.lineLabel = lineData.lineLabel;
062         this.formula = new String[lineData.formula.length];
063         System.arraycopy(lineData.formula, 0this.formula, 0, lineData.formula.length);
064         this.reason = new String[lineData.reason.length];
065         System.arraycopy(lineData.reason, 0this.reason, 0, lineData.reason.length);
066     }
067 
068     /**
069      * Empty data.
070      */
071     public void init() {
072         this.lineLabel = "";
073         this.formula = new String[0];
074         this.reason = new String[0];
075     }
076 
077     /**
078      * Exists formula data or reason data?
079      *
080      @return  Is there any reason or formula data?
081      */
082     public boolean containsData() {
083         return (!= lines());
084     }
085 
086     /**
087      * How many lines do we have? This is maximum of formula lines and reason lines.
088      *
089      @return  Number of lines.
090      */
091     public int lines() {
092         return Math.max(getFormula().length, getReason().length);
093     }
094 
095     public String getLineLabel() {
096         return lineLabel;
097     }
098 
099     public void setLineLabel(final String lineLabel) {
100         this.lineLabel = lineLabel;
101     }
102 
103     public String[] getFormula() {
104         return formula;
105     }
106 
107     public void setFormula(final String[] formula) {
108         this.formula = formula;
109     }
110 
111     public String[] getReason() {
112         return reason;
113     }
114 
115     public void setReason(final String[] reason) {
116         this.reason = reason;
117     }
118 
119 }