Class MathNode

All Implemented Interfaces:
IParsedExpression, Node, Serializable

public class MathNode extends ExpressionNode
Math node performs mathematical operations on it's (one or two) child nodes.
See Also:
  • Field Details

  • Constructor Details

    • MathNode

      public MathNode(jadex.javaparser.javaccimpl.ParserImpl p, int id)
      Create a node.
      Parameters:
      p - The parser.
      id - The id.
  • Method Details

    • setText

      public void setText(String text)
      Set the token text.
      Overrides:
      setText in class ExpressionNode
      Parameters:
      text - The token text.
    • precompile

      public void precompile()
      Precompute the static type and constant value if possible.
      Overrides:
      precompile in class ExpressionNode
    • getValue

      public Object getValue(jadex.common.IValueFetcher fetcher)
      Evaluate the expression in the given state with respect to given parameters.
      Specified by:
      getValue in interface IParsedExpression
      Specified by:
      getValue in class ExpressionNode
      Parameters:
      params - The parameters (string, value pairs), if any.
      Returns:
      The value of the term.
    • precompileUnary

      protected void precompileUnary()
      Precompile unary node.
    • getUnaryValue

      public Object getUnaryValue(jadex.common.IValueFetcher fetcher)
      Evaluate the term.
      Parameters:
      params - The parameters (string, value).
      Returns:
      The value of the term.
    • toPlainString

      public String toPlainString()
      Create a string representation of this node and its subnodes.
      Specified by:
      toPlainString in interface Node
      Overrides:
      toPlainString in class ExpressionNode
      Returns:
      A string representation of this node.
    • toString

      public static String toString(int operator)
      Convert an operator to a string representation.
      Parameters:
      operator - The operator
      Returns:
      A string representation of the operator.
    • fromString

      public static int fromString(String operator)
      Convert an operator from a string representation.
      Parameters:
      operator - The operator as string.
      Returns:
      The int value of the operator.
    • equals

      public boolean equals(Object o)
      Test if two nodes are equal.
      Overrides:
      equals in class ExpressionNode
    • hashCode

      public int hashCode()
      Get the hash code for the node.
      Overrides:
      hashCode in class ExpressionNode