de.matthiasmann.twl.utils
Class AbstractMathInterpreter

java.lang.Object
  extended by de.matthiasmann.twl.utils.AbstractMathInterpreter
All Implemented Interfaces:
SimpleMathParser.Interpreter

public abstract class AbstractMathInterpreter
extends java.lang.Object
implements SimpleMathParser.Interpreter


Nested Class Summary
static interface AbstractMathInterpreter.Function
           
static class AbstractMathInterpreter.NumberFunction
           
 
Constructor Summary
AbstractMathInterpreter()
           
 
Method Summary
 void accessArray()
           
protected  java.lang.Object accessField(java.lang.Object obj, java.lang.String field)
           
 void accessField(java.lang.String field)
           
 void add()
           
 void callFunction(java.lang.String name, int args)
           
 void div()
           
 java.lang.Number execute(java.lang.String str)
           
<T> T
executeCreateObject(java.lang.String str, java.lang.Class<T> type)
           
 int[] executeIntArray(java.lang.String str)
           
protected static boolean isFloat(java.lang.Number n)
           
 void loadConst(java.lang.Number n)
           
 void mul()
           
 void negate()
           
protected  java.lang.Object pop()
           
protected  java.lang.Number popNumber()
           
protected  void push(java.lang.Object obj)
           
 void registerFunction(java.lang.String name, AbstractMathInterpreter.Function function)
           
 void sub()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.matthiasmann.twl.utils.SimpleMathParser.Interpreter
accessVariable
 

Constructor Detail

AbstractMathInterpreter

public AbstractMathInterpreter()
Method Detail

registerFunction

public final void registerFunction(java.lang.String name,
                                   AbstractMathInterpreter.Function function)

execute

public java.lang.Number execute(java.lang.String str)
                         throws java.text.ParseException
Throws:
java.text.ParseException

executeIntArray

public int[] executeIntArray(java.lang.String str)
                      throws java.text.ParseException
Throws:
java.text.ParseException

executeCreateObject

public <T> T executeCreateObject(java.lang.String str,
                                 java.lang.Class<T> type)
                      throws java.text.ParseException
Throws:
java.text.ParseException

push

protected void push(java.lang.Object obj)

pop

protected java.lang.Object pop()

popNumber

protected java.lang.Number popNumber()

loadConst

public void loadConst(java.lang.Number n)
Specified by:
loadConst in interface SimpleMathParser.Interpreter

add

public void add()
Specified by:
add in interface SimpleMathParser.Interpreter

sub

public void sub()
Specified by:
sub in interface SimpleMathParser.Interpreter

mul

public void mul()
Specified by:
mul in interface SimpleMathParser.Interpreter

div

public void div()
Specified by:
div in interface SimpleMathParser.Interpreter

negate

public void negate()
Specified by:
negate in interface SimpleMathParser.Interpreter

accessArray

public void accessArray()
Specified by:
accessArray in interface SimpleMathParser.Interpreter

accessField

public void accessField(java.lang.String field)
Specified by:
accessField in interface SimpleMathParser.Interpreter

accessField

protected java.lang.Object accessField(java.lang.Object obj,
                                       java.lang.String field)

callFunction

public void callFunction(java.lang.String name,
                         int args)
Specified by:
callFunction in interface SimpleMathParser.Interpreter

isFloat

protected static boolean isFloat(java.lang.Number n)