com.epochx.representation
Class Variable<TYPE>

java.lang.Object
  extended by com.epochx.representation.Node<TYPE>
      extended by com.epochx.representation.TerminalNode<TYPE>
          extended by com.epochx.representation.Variable<TYPE>
All Implemented Interfaces:
java.lang.Cloneable

public class Variable<TYPE>
extends TerminalNode<TYPE>

A variable is a data type which can be used as a TerminalNode in place of a predefined constant. Variables can thus have their values changed which will change the result of evaluation.


Constructor Summary
Variable(java.lang.String label)
          Constructor for a new variable instance.
 
Method Summary
 java.lang.Object clone()
          Variables cannot be cloned.
 boolean equals(java.lang.Object obj)
          Compares an object for equivalence to this instance of Variable.
 java.lang.String getLabel()
          Returns the label of the variable.
 void setLabel(java.lang.String label)
          Replaces the variable's label with a new name.
 java.lang.String toString()
          Return a string representation of the variable.
 
Methods inherited from class com.epochx.representation.TerminalNode
evaluate, getValue, hashCode, setValue
 
Methods inherited from class com.epochx.representation.Node
getArity, getChild, getChildren, getDepth, getFunctionNodes, getLength, getNodesAtDepth, getNoDistinctFunctions, getNoDistinctTerminals, getNoFunctions, getNoTerminals, getNthNode, getTerminalNodes, setChild, setChildren, setNthNode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Variable

public Variable(java.lang.String label)
Constructor for a new variable instance.

Parameters:
label - the variable's name.
Method Detail

getLabel

public java.lang.String getLabel()
Returns the label of the variable.

Returns:
the label of the variable.

setLabel

public void setLabel(java.lang.String label)
Replaces the variable's label with a new name.

Parameters:
label - the new label to assign to the variable.

toString

public java.lang.String toString()
Return a string representation of the variable.

Overrides:
toString in class TerminalNode<TYPE>
Returns:
a string representation of this variable.

equals

public boolean equals(java.lang.Object obj)
Compares an object for equivalence to this instance of Variable. Two variables are equal if they have equal labels and equal values.

Overrides:
equals in class TerminalNode<TYPE>
Parameters:
obj - an object to compare for equivalence.
Returns:
true if the object is a variable equal to this one, false otherwise.

clone

public java.lang.Object clone()
Variables cannot be cloned. Calling this method returns the same instance of Variable as this allows a variable to be treated in the same way as other nodes without preventing variable values being updateable throughout a program tree.

Overrides:
clone in class TerminalNode<TYPE>
Returns:
this instance of Variable.