no.sesat
Class Interpreter

java.lang.Object
  extended by no.sesat.Interpreter

public class Interpreter
extends Object

Simple interpreter that will start if a console is available. You can add functions to it by using addFunction(String, Function).


Nested Class Summary
static class Interpreter.Context
          Context for a function.
static class Interpreter.Function
          Function that you can implement if you want to add a function to this Interpreter.
 
Field Summary
static boolean ENABLED
           
 
Constructor Summary
Interpreter()
           
 
Method Summary
static void addFunction(String name, Interpreter.Function fun)
          Add a function to this Interpreter.
static String eval(String expr)
          Evaluate the expression
static void removeFunction(String name)
          Remove function from interpreter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENABLED

public static final boolean ENABLED
Constructor Detail

Interpreter

public Interpreter()
Method Detail

addFunction

public static void addFunction(String name,
                               Interpreter.Function fun)
Add a function to this Interpreter.

Parameters:
name - Name of function
fun - The function

removeFunction

public static void removeFunction(String name)
Remove function from interpreter.

Parameters:
name - Named function

eval

public static String eval(String expr)
Evaluate the expression

Parameters:
expr - to be evaluated.
Returns:
result


Copyright © 2009 Schibsted Søk AS. All Rights Reserved.