Class CompiledExpression

java.lang.Object
redempt.crunch.CompiledExpression

public class CompiledExpression extends Object
An expression which has been compiled with Crunch.compileExpression(String) and can be evaluated with evaluate(double...)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected double[]
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
     
    CompiledExpression(Value value, int variableCount)
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    double
    Evaluates this CompiledExpression and returns its value without modifying variable values
    double
    evaluate(double first)
    Evaluates this CompiledExpression and returns its value
    double
    evaluate(double... values)
    Evaluates this CompiledExpression and returns its value
    double
    evaluate(double first, double second)
    Evaluates this CompiledExpression and returns its value
    Gets the internal Value representation of the expression.
    int
    Gets the highest index of variables used in this expression.
    protected void
    initialize(Value value, int variableCount)
     
    protected void
    setVariableValues(double[] values)
     
    Converts this CompiledExpression back to a String which can be used to recreate it later

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • variableValues

      protected double[] variableValues
  • Constructor Details

    • CompiledExpression

      protected CompiledExpression()
    • CompiledExpression

      public CompiledExpression(Value value, int variableCount)
  • Method Details

    • initialize

      protected void initialize(Value value, int variableCount)
    • setVariableValues

      protected void setVariableValues(double[] values)
    • getValue

      public Value getValue()
      Gets the internal Value representation of the expression. This is essentially reflection into the expression. Proceed at your own risk.
      Returns:
      The Value this CompiledExpression wraps
    • getVariableCount

      public int getVariableCount()
      Gets the highest index of variables used in this expression. Any call to evaluate(double...) must pass at least this many values.
      Returns:
      The number of variables used in this expression
    • evaluate

      public double evaluate(double... values)
      Evaluates this CompiledExpression and returns its value
      Parameters:
      values - The values for variables used in this expression, in order starting with 1
      Returns:
      The resulting value
    • evaluate

      public double evaluate()
      Evaluates this CompiledExpression and returns its value without modifying variable values
      Returns:
      The resulting value
    • evaluate

      public double evaluate(double first)
      Evaluates this CompiledExpression and returns its value
      Parameters:
      first - The first variable value
      Returns:
      The resulting value
    • evaluate

      public double evaluate(double first, double second)
      Evaluates this CompiledExpression and returns its value
      Parameters:
      first - The first variable value
      second - The second variable value
      Returns:
      The resulting value
    • clone

      public CompiledExpression clone()
      Overrides:
      clone in class Object
      Returns:
      A clone of this CompiledExpression
    • toString

      public String toString()
      Converts this CompiledExpression back to a String which can be used to recreate it later
      Overrides:
      toString in class Object
      Returns:
      A String representation of this CompiledExpression