ac.essex.ooechs.ecj.ecj2java.nodes
Class ParseableGPNode

java.lang.Object
  extended by ec.gp.GPNode
      extended by ac.essex.ooechs.ecj.ecj2java.nodes.ParseableGPNode
All Implemented Interfaces:
ParseableNode, ec.gp.GPNodeParent, ec.Prototype, ec.Setup, java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
X

public abstract class ParseableGPNode
extends ec.gp.GPNode
implements ParseableNode

An abstract class which allows us to save a node and run it again at a later time. It is able to interface the GP node class with the parseableNode class. The only code that your GP code needs to make is to add the "getJavaCode()" function to your class and implement this abstract class.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version, provided that any use properly credits the author. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org

Version:
1.0
Author:
Olly Oechsle, University of Essex, Date: 05-Sep-2006
See Also:
Serialized Form

Field Summary
(package private)  int numChildren
          The amount of children this node is SUPPOSED to have
(package private)  java.lang.String text
          The name of this node - text is used by the GPNode's toString function
(package private)  int type
          The type of node - Terminal, Function or ERC - used by the JavaWriter
(package private)  java.lang.String variableName
           
 
Fields inherited from class ec.gp.GPNode
argposition, children, constraints, GPNODEPRINTTAB, MAXPRINTBYTES, NODESEARCH_ALL, NODESEARCH_CUSTOM, NODESEARCH_NONTERMINALS, NODESEARCH_TERMINALS, P_NODE, P_NODECONSTRAINTS, parent, REPLACEMENT_CHAR, SITUATION_MUTATION, SITUATION_NEWIND
 
Fields inherited from interface ac.essex.ooechs.ecj.ecj2java.nodes.ParseableNode
BOOLEAN, DOUBLE, ERC, FUNCTION, INT, RETURN, VOID
 
Constructor Summary
ParseableGPNode(java.lang.String text, int numChildren)
          Initialises the GP node and sets the type as a function.
ParseableGPNode(java.lang.String text, int numChildren, int type)
           
 
Method Summary
 void checkConstraints(ec.EvolutionState state, int tree, ec.gp.GPIndividual typicalIndividual, ec.util.Parameter individualBase)
           
 int countChildren()
          Returns how many children this node has
 ParseableNode getChild(int index)
          Gets the child of this node at a given index.
 java.lang.String getEndJavaCode()
           
abstract  java.lang.String getJavaCode()
          Returns a string representation of the java statement represented by this node.
 java.lang.String getLineComment()
          There may be a line comment associated with this piece of code.
abstract  int getObjectType()
          The kind of object this is, eg int, double, etc.
 int getType()
          Returns what kind of node this is.
 java.lang.String getValue()
           
 java.lang.String getVariableName()
          When the java writer uses this node, it may use a variable name to describe it.
 void setType(int type)
          Set the node type
 void setVariableName(java.lang.String name)
          Attaches a variable name to this node, used by JavaWriter
 java.lang.String toString()
           
 
Methods inherited from class ec.gp.GPNode
atDepth, cloneReplacing, cloneReplacing, cloneReplacing, cloneReplacingAtomic, cloneReplacingAtomic, cloneReplacingAtomicSimple, cloneReplacingAtomicSimple, cloneReplacingNoSubclone, cloneReplacingNoSubcloneSimple, cloneReplacingSimple, cloneReplacingSimple, cloneReplacingSimple, constraints, contains, defaultBase, depth, errorInfo, eval, makeCTree, makeLatexTree, nodeEquals, nodeEquivalentTo, nodeHashCode, nodeInPosition, numNodes, numNodes, parentType, printNode, printNode, printNodeForHumans, printRootedTree, printRootedTree, printRootedTreeForHumans, protoClone, protoCloneSimple, readNode, readNode, readRootedTree, readRootedTree, replaceWith, resetNode, rootedTreeEquals, rootedTreeHashCode, rootParent, setup, swapCompatibleWith, toStringForError, toStringForHumans, writeNode, writeRootedTree
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

numChildren

int numChildren
The amount of children this node is SUPPOSED to have


type

int type
The type of node - Terminal, Function or ERC - used by the JavaWriter


text

java.lang.String text
The name of this node - text is used by the GPNode's toString function


variableName

java.lang.String variableName
Constructor Detail

ParseableGPNode

public ParseableGPNode(java.lang.String text,
                       int numChildren)
Initialises the GP node and sets the type as a function.

Parameters:
text -
numChildren -

ParseableGPNode

public ParseableGPNode(java.lang.String text,
                       int numChildren,
                       int type)
Method Detail

checkConstraints

public void checkConstraints(ec.EvolutionState state,
                             int tree,
                             ec.gp.GPIndividual typicalIndividual,
                             ec.util.Parameter individualBase)
Overrides:
checkConstraints in class ec.gp.GPNode

getJavaCode

public abstract java.lang.String getJavaCode()
Returns a string representation of the java statement represented by this node.

Specified by:
getJavaCode in interface ParseableNode

getEndJavaCode

public java.lang.String getEndJavaCode()

toString

public java.lang.String toString()
Specified by:
toString in class ec.gp.GPNode

getChild

public ParseableNode getChild(int index)
Description copied from interface: ParseableNode
Gets the child of this node at a given index.

Specified by:
getChild in interface ParseableNode

countChildren

public int countChildren()
Description copied from interface: ParseableNode
Returns how many children this node has

Specified by:
countChildren in interface ParseableNode

getVariableName

public java.lang.String getVariableName()
When the java writer uses this node, it may use a variable name to describe it.

Specified by:
getVariableName in interface ParseableNode

setVariableName

public void setVariableName(java.lang.String name)
Attaches a variable name to this node, used by JavaWriter

Specified by:
setVariableName in interface ParseableNode

getType

public int getType()
Description copied from interface: ParseableNode
Returns what kind of node this is.

Specified by:
getType in interface ParseableNode

setType

public void setType(int type)
Description copied from interface: ParseableNode
Set the node type

Specified by:
setType in interface ParseableNode

getValue

public java.lang.String getValue()

getObjectType

public abstract int getObjectType()
Description copied from interface: ParseableNode
The kind of object this is, eg int, double, etc.

Specified by:
getObjectType in interface ParseableNode

getLineComment

public java.lang.String getLineComment()
Description copied from interface: ParseableNode
There may be a line comment associated with this piece of code.

Specified by:
getLineComment in interface ParseableNode