CogPar
A versatile parser for mathematical expressions.
 All Classes Functions Variables
Public Member Functions | Private Attributes | List of all members
uk.co.cogitolearning.cogpar.VariableExpressionNode Class Reference

An ExpressionNode that stores a named variable. More...

Inheritance diagram for uk.co.cogitolearning.cogpar.VariableExpressionNode:
Inheritance graph
[legend]
Collaboration diagram for uk.co.cogitolearning.cogpar.VariableExpressionNode:
Collaboration graph
[legend]

Public Member Functions

 VariableExpressionNode (String name)
 Construct with the name of the variable.
String getName ()
int getType ()
 Returns the type of the node, in this case ExpressionNode.VARIABLE_NODE.
void setValue (double value)
 Sets the value of the variable.
double getValue ()
 Returns the value of the variable but throws an exception if the value has not been set.
void accept (ExpressionNodeVisitor visitor)
 Implementation of the visitor design pattern.

Private Attributes

String name
 The name of the variable.
double value
 The value of the variable.
boolean valueSet
 indicates if the value has been set

Additional Inherited Members

- Static Public Attributes inherited from uk.co.cogitolearning.cogpar.ExpressionNode
static final int VARIABLE_NODE = 1
 Node id for variable nodes.
static final int CONSTANT_NODE = 2
 Node id for constant nodes.
static final int ADDITION_NODE = 3
 Node id for addition nodes.
static final int MULTIPLICATION_NODE = 4
 Node id for multiplication nodes.
static final int EXPONENTIATION_NODE = 5
 Node id for exponentiation nodes.
static final int FUNCTION_NODE = 6
 Node id for function nodes.

Detailed Description

An ExpressionNode that stores a named variable.

Definition at line 30 of file VariableExpressionNode.java.

Constructor & Destructor Documentation

uk.co.cogitolearning.cogpar.VariableExpressionNode.VariableExpressionNode ( String  name)

Construct with the name of the variable.

Parameters
namethe name of the variable

Definition at line 45 of file VariableExpressionNode.java.

Member Function Documentation

void uk.co.cogitolearning.cogpar.VariableExpressionNode.accept ( ExpressionNodeVisitor  visitor)

Implementation of the visitor design pattern.

Calls visit on the visitor.

Parameters
visitorthe visitor

Implements uk.co.cogitolearning.cogpar.ExpressionNode.

Definition at line 99 of file VariableExpressionNode.java.

String uk.co.cogitolearning.cogpar.VariableExpressionNode.getName ( )
Returns
the name of the variable

Definition at line 54 of file VariableExpressionNode.java.

void uk.co.cogitolearning.cogpar.VariableExpressionNode.setValue ( double  value)

Sets the value of the variable.

Parameters
valuethe value of the variable

Definition at line 73 of file VariableExpressionNode.java.


The documentation for this class was generated from the following file: