01: package gnu.mapping;
02:
03: /**
04: * Abstract class for 2-argument Scheme procedures.
05: * Extensions must provide apply2.
06: * @author Per Bothner
07: */
08:
09: public abstract class Procedure2 extends Procedure {
10:
11: public Procedure2(java.lang.String n) {
12: super (n);
13: }
14:
15: public Procedure2() {
16: super ();
17: }
18:
19: public int numArgs() {
20: return 0x2002;
21: }
22:
23: public Object apply0() throws Throwable {
24: throw new WrongArguments(this .getName(), 2, "(?)");
25: }
26:
27: public Object apply1(Object arg1) throws Throwable {
28: throw new WrongArguments(this , 1);
29: }
30:
31: public abstract Object apply2(Object arg1, Object arg2)
32: throws Throwable;
33:
34: public Object apply3(Object arg1, Object arg2, Object arg3) {
35: throw new WrongArguments(this , 3);
36: }
37:
38: public Object apply4(Object arg1, Object arg2, Object arg3,
39: Object arg4) throws Throwable {
40: throw new WrongArguments(this , 4);
41: }
42:
43: public Object applyN(Object[] args) throws Throwable {
44: if (args.length != 2)
45: throw new WrongArguments(this , args.length);
46: return apply2(args[0], args[1]);
47: }
48: }
|