net.cscott.sdr.calls
Class CallDB
java.lang.Object
net.cscott.sdr.calls.CallDB
public class CallDB
- extends Object
CallDB holds all the calls and concepts we know about.
It is a singleton class; its static constructor loads
all the call definitions from files and other classes.
- Author:
- C. Scott Ananian
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
INSTANCE
public static final CallDB INSTANCE
allCalls
public final Collection<Call> allCalls
lookup
public Call lookup(String name)
- Lookup a call in the database.
- Throws:
IllegalArgumentException
- if the call name is
unknown.- Tests:
Basic lookup test:
js> db = CallDB.INSTANCE
net.cscott.sdr.calls.CallDB@1d66e22
js> db.lookup("square thru")
square thru[basic]
Check that exceptions are properly thrown for bogus calls:
js> try {
> CallDB.INSTANCE.lookup("foobar bat")
> } catch (e) {
> print(e.javaException)
> }
java.lang.IllegalArgumentException: Unknown call: foobar bat
parse
public Apply parse(Program program,
String s)
- Parse a natural-language string of calls.
- Tests:
js> db = CallDB.INSTANCE
net.cscott.sdr.calls.CallDB@1d66e22
js> db.parse(Program.BASIC, "double pass thru")
(Apply double pass thru)
js> db.parse(Program.BASIC, "square thru three and a half")
(Apply square thru (Apply 3 1/2))
Copyright © 2006-2009 C. Scott Ananian