info.bliki.wiki.template.expr.eval
Class DoubleEvaluator

java.lang.Object
  extended by info.bliki.wiki.template.expr.eval.DoubleEvaluator

public class DoubleEvaluator
extends java.lang.Object

Evaluate math expressions to double numbers. Use the expression syntax describe here: http://meta.wikimedia.org/wiki/Help:ParserFunctions#.23expr:


Field Summary
static double EPSILON
          A "close to zero" double epsilon value for use to compare with 0.0
static double EPSILON_ROUND
          A "close to zero" double epsilon value for use in the Round function
 
Constructor Summary
DoubleEvaluator()
           
DoubleEvaluator(ASTNode node)
           
 
Method Summary
 double evaluate()
          Reevaluate the expression (possibly after a new Variable assignment)
 double evaluate(java.lang.String expression)
          Parse the given expression String and evaluate it to a double value
 double evaluateFunction(FunctionNode functionNode)
          Evaluate an already parsed in FunctionNode into a souble number value.
 boolean evaluateFunctionLogical(FunctionNode functionNode)
           
 double evaluateNode(ASTNode node)
          Evaluate an already parsed in abstract syntax tree node into a double number value.
 boolean evaluateNodeLogical(ASTNode node)
           
 ASTNode optimizeFunction(FunctionNode functionNode)
          Optimize an already parsed in functionNode into an ASTNode.
 ASTNode parse(java.lang.String expression)
          Parse the given expression String and store the resulting ASTNode in this DoubleEvaluator
static ASTNode parseNode(java.lang.String expression)
          Parse the given expression String and return the resulting ASTNode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EPSILON

public static double EPSILON
A "close to zero" double epsilon value for use to compare with 0.0


EPSILON_ROUND

public static double EPSILON_ROUND
A "close to zero" double epsilon value for use in the Round function

Constructor Detail

DoubleEvaluator

public DoubleEvaluator()

DoubleEvaluator

public DoubleEvaluator(ASTNode node)
Method Detail

parse

public ASTNode parse(java.lang.String expression)
Parse the given expression String and store the resulting ASTNode in this DoubleEvaluator

Parameters:
expression -
Returns:
Throws:
SyntaxError

parseNode

public static ASTNode parseNode(java.lang.String expression)
Parse the given expression String and return the resulting ASTNode

Parameters:
expression -
Returns:
Throws:
SyntaxError

evaluate

public double evaluate(java.lang.String expression)
Parse the given expression String and evaluate it to a double value

Parameters:
expression -
Returns:
Throws:
SyntaxError

evaluate

public double evaluate()
Reevaluate the expression (possibly after a new Variable assignment)

Parameters:
expression -
Returns:
Throws:
SyntaxError

evaluateNode

public double evaluateNode(ASTNode node)
Evaluate an already parsed in abstract syntax tree node into a double number value.

Parameters:
node - abstract syntax tree node
Returns:
the evaluated double number
Throws:
java.lang.ArithmeticException - if the node cannot be evaluated.

evaluateFunction

public double evaluateFunction(FunctionNode functionNode)
Evaluate an already parsed in FunctionNode into a souble number value.

Parameters:
functionNode -
Returns:
Throws:
java.lang.ArithmeticException - if the functionNode cannot be evaluated.

evaluateNodeLogical

public boolean evaluateNodeLogical(ASTNode node)

evaluateFunctionLogical

public boolean evaluateFunctionLogical(FunctionNode functionNode)

optimizeFunction

public ASTNode optimizeFunction(FunctionNode functionNode)
Optimize an already parsed in functionNode into an ASTNode.

Parameters:
functionNode -
Returns:


Copyright © 2012 Java Wikipedia API (Bliki engine). All Rights Reserved.