Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.


#3 Convenience syntax for custom objects

Sergey Kosigin

i suggest insert
such object which will redefine convenience syntax for
self, overload operations(+,-,*,(cast operation)..), and will
receive interpreter in constructor as parameter
It will be used for customizing beanshell script for
custom systems without rewriting source code

This object can have the next syntax:

abstract class CustomObject {
public CustomObject(Interpreter interpreter);

/** replace this + rightOperand string in script text*/
Object add(Object rightOperand) throw Exception;

/** replace this * rightOperand string in script text*/
Object multiply(Object rightOperand) throw Exception;

/** resolves next token
example myObject.a.b.c
if(myObject instanceof CustomObject)
try {
return ((CustomObject)myObject).point("a");
} catch (FieldNotFoundException e) {
other field resolving methods
Object point(String fieldName) throw
FieldNotFoundException, Exception;

* cast operations (CustomObject)value implementation
CustomObject cast(Object value) throw
NotPossibleCast, Exception;

or other case than exists 2 object one have method for
operation on another object

public interface CustomObject {
protected Adapter getAdapter();

public interface Adapter {
protected Object add(CustomObject a, Object b);
protected Object subtr