Algernon Software

org.algernon.lang.java
Class JavaEvaluator

java.lang.Object
  extended byorg.algernon.lang.java.JavaEvaluator
All Implemented Interfaces:
ExternalLanguageEvaluator

public class JavaEvaluator
extends Object
implements ExternalLanguageEvaluator

Evaluator for java method calls and expressions. User: hewett Date: Dec 10, 2002 Time: 4:30:06 PM


Constructor Summary
JavaEvaluator()
           
 
Method Summary
 Object evaluateExpression(LispValue expression, Algernon algy)
          Evaluates a method call.
protected  String resolveClassName(String s)
          Returns a fully-qualified Java class name.
protected  String resolveMethodName(String s)
           
 Boolean toBoolean(Object any, Algernon algy)
          This method must return a Java Boolean value for any type of Object returned by the evaluateExpression method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaEvaluator

public JavaEvaluator()
Method Detail

toBoolean

public Boolean toBoolean(Object any,
                         Algernon algy)
This method must return a Java Boolean value for any type of Object returned by the evaluateExpression method. For example, null might correspond to Boolean.False,

Specified by:
toBoolean in interface ExternalLanguageEvaluator
Parameters:
any - any Java Object, including null.
Returns:
a Java Boolean instance.

evaluateExpression

public Object evaluateExpression(LispValue expression,
                                 Algernon algy)
Evaluates a method call. The class is instantiated, the method on that class is found, and the method is called on the object with the given parameters.

The method name should be class.method. The class lookup method looks for the class in two places: the given package (which may be no package) and the default package (org.algernonx). Case is significant in Java, but not in Algernon, so put the method name in double quotes.

   (:TEST (:JAVA ("org.mypackage.mysubpackage.UsefulRoutines.testMethod1" ?arg)))
 

Specified by:
evaluateExpression in interface ExternalLanguageEvaluator
Parameters:
expression - A method call in Java.
Returns:
the object returned by the method.

resolveMethodName

protected String resolveMethodName(String s)

resolveClassName

protected String resolveClassName(String s)
Returns a fully-qualified Java class name.

Parameters:
s -
Returns:
a fully-qualified Java class name.

Algernon Software