001    package org.jaga.reproduction.booleanFormulas.nodes;
002    
003    /**
004     * TODO: Complete these comments.
005     *
006     * <p><u>Project:</u> JAGA - Java API for Genetic Algorithms.</p>
007     *
008     * <p><u>Company:</u> University College London and JAGA.Org
009     *    (<a href="http://www.jaga.org" target="_blank">http://www.jaga.org</a>).
010     * </p>
011     *
012     * <p><u>Copyright:</u> (c) 2004 by G. Paperin.<br/>
013     *    This program is free software; you can redistribute it and/or modify
014     *    it under the terms of the GNU General Public License as published by
015     *    the Free Software Foundation, ONLY if you include a note of the original
016     *    author(s) in any redistributed/modified copy.<br/>
017     *    This program is distributed in the hope that it will be useful,
018     *    but WITHOUT ANY WARRANTY; without even the implied warranty of
019     *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
020     *    GNU General Public License for more details.<br/>
021     *    You should have received a copy of the GNU General Public License
022     *    along with this program; if not, write to the Free Software
023     *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
024     *    or see http://www.gnu.org/licenses/gpl.html</p>
025     *
026     * @author Greg Paperin (greg@jaga.org)
027     *
028     * @version JAGA public release 1.0 beta
029     */
030    
031    abstract public class BooleanFormulaTreeNode {
032    
033            private OperatorNode parent = null;
034            private int depth = 0;
035            private int height = 1;
036            private Long handle = new Long(0);
037    
038            public BooleanFormulaTreeNode() {}
039    
040            abstract public boolean evaluate(boolean [] parameters);
041    
042            abstract public int getRequiredChildrenNumber();
043    
044            abstract public Object clone();
045    
046            abstract public int recalcHeight();
047    
048            public int getHeight() {
049                    return height;
050            }
051    
052            protected void setHeight(int val) {
053                    height = val;
054            }
055    
056            public String toString() {
057                    return toString(true);
058            }
059    
060            public String toString(boolean infix) {
061                    return toStringBuffer(infix).toString();
062            }
063    
064            abstract public StringBuffer toStringBuffer(boolean infix);
065    
066            public OperatorNode getParent() {
067                    return this.parent;
068            }
069    
070            protected void setParent(OperatorNode parent) {
071                    this.parent = parent;
072            }
073    
074            public int getDepth() {
075                    return this.depth;
076            }
077    
078            public void setDepth(int depth) {
079                    this.depth = depth;
080            }
081    
082            public Long getHandle() {
083                    return this.handle;
084            }
085    
086            public void setHandle(Long handle) {
087                    this.handle = handle;
088            }
089    
090    }