vec_math
Class ExpressionNode

java.lang.Object
  extended by vec_math.Node<String>
      extended by vec_math.StringNode
          extended by vec_math.ExpressionNode
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ExpressionFunction, ExpressionMultidimensional

public class ExpressionNode
extends StringNode

A node class for ExpressionParser. This node deals with Number instances, i.e. Double and Long, and the Boolean class. Though internally handled as objects, the final expression is always one of these types and can readily be cast.

See Also:
Serialized Form

Nested Class Summary
static class ExpressionNode.Test
          Test purposes only.
 
Constructor Summary
ExpressionNode(String root)
          Constructs a new top-level double node.
ExpressionNode(StringNode parent, String root, int level)
          Constructs a daugther node.
 
Method Summary
 String getValue()
          Cast a String to the appropriate type of a Number or Boolean instance.
protected  boolean isVariable(String arg)
          Test if the argument is a variable or a constant double.
 
Methods inherited from class vec_math.StringNode
getVariables, parseOperator, parseSub, replaceVariable, replaceVariable, setValidOperator
 
Methods inherited from class vec_math.Node
equals, getLevel, getParent, getParseSource, getSub, getSubAt, getSubNodeNumber, getTie, isFinal, isParsed, isRoot, parse, parse, setParse, setParseSource, setSub, setTie, setValue, toString, traceVariable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExpressionNode

public ExpressionNode(String root)
Constructs a new top-level double node. Parsing a string expression will always start with a call to this constructor, therefore the valid operators are also set here.


ExpressionNode

public ExpressionNode(StringNode parent,
                      String root,
                      int level)
Constructs a daugther node. This constructor is called repeatedly during parsing.

Method Detail

isVariable

protected boolean isVariable(String arg)
Test if the argument is a variable or a constant double. Variables must be replaced before evaluating with their numeric content.

The argument must be of type String. This string is then tested in the following ways:

Overrides:
isVariable in class StringNode

getValue

public String getValue()
Cast a String to the appropriate type of a Number or Boolean instance. The approach is as this: