source: branches/streams/abcl/examples/java-interface/BankExampleMain.java

Last change on this file was 13186, checked in by Mark Evenson, 14 years ago

Add a slightly simpler example of implemeting a Java interface in Lisp.

TODO Needs further documentation.

File size: 900 bytes
Line 
1import org.armedbear.lisp.Interpreter;
2import org.armedbear.lisp.Symbol;
3import org.armedbear.lisp.Packages;
4import org.armedbear.lisp.JavaObject;
5import org.armedbear.lisp.LispObject;
6
7public class BankExampleMain 
8{
9  static public void main(String argv[]) {
10    Interpreter interpreter = Interpreter.createInstance();
11    interpreter.eval("(load \"bank-account.lisp\")");
12    org.armedbear.lisp.Package defaultPackage
13      = Packages.findPackage("CL-USER");
14    Symbol bankAccountImplSymbol
15      = defaultPackage.findAccessibleSymbol("*BANK-ACCOUNT-IMPL*");
16    LispObject value = bankAccountImplSymbol.symbolValue();
17    Object object =  ((JavaObject) value).getObject();
18    BankAccount account = (BankAccount) object;
19    System.out.println("Initial balance: " + account.getBalance());
20    account.withdraw(500);
21    System.out.println("After withdrawing 500: " + account.getBalance());
22  }
23}
Note: See TracBrowser for help on using the repository browser.