org.shiftone.bigcalc
Class Calculator

java.lang.Object
  extended byorg.shiftone.bigcalc.Calculator
All Implemented Interfaces:
Functor

public class Calculator
extends java.lang.Object
implements Functor

This is the main class that should be used to turn a string into a functor. Once instanciated, this functor's behavior will be based on the string's expression. Instances of this class are thread safe, as should be all functors. It is most efficient if functor instances like this one are reused rather than parsed over and over again.

Version:
$Revision: 1.13 $
Author:
$Author: jeffdrost $

Constructor Summary
Calculator(java.lang.String text)
           
 
Method Summary
 java.lang.Object evaluate(Context context)
           
static void main(java.lang.String[] args)
           
static Functor parse(java.lang.String text, FunctorFactory functorFactory)
           
 java.lang.String print(Context context)
           
 void print(java.lang.StringBuffer sb, Context context)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Calculator

public Calculator(java.lang.String text)
           throws java.lang.Exception
Method Detail

evaluate

public java.lang.Object evaluate(Context context)
                          throws java.lang.Exception
Specified by:
evaluate in interface Functor
Throws:
java.lang.Exception

print

public void print(java.lang.StringBuffer sb,
                  Context context)
           throws java.lang.Exception
Specified by:
print in interface Functor
Throws:
java.lang.Exception

print

public java.lang.String print(Context context)
                       throws java.lang.Exception
Throws:
java.lang.Exception

parse

public static Functor parse(java.lang.String text,
                            FunctorFactory functorFactory)
                     throws ParseException
Throws:
ParseException

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception

toString

public java.lang.String toString()