01: package gnu.mapping;
02:
03: /**
04: * Abstract class for "N-argument" Scheme procedures, where N>4 or variable.
05: * @author Per Bothner
06: */
07:
08: public abstract class ProcedureN extends Procedure {
09: public ProcedureN() {
10: super ();
11: }
12:
13: public ProcedureN(String n) {
14: super (n);
15: }
16:
17: public static final Object[] noArgs = new Object[0];
18:
19: public Object apply0() throws Throwable {
20: return applyN(noArgs);
21: }
22:
23: public Object apply1(Object arg1) throws Throwable {
24: Object[] args = new Object[1];
25: args[0] = arg1;
26: return applyN(args);
27: }
28:
29: public Object apply2(Object arg1, Object arg2) throws Throwable {
30: Object[] args = new Object[2];
31: args[0] = arg1;
32: args[1] = arg2;
33: return applyN(args);
34: }
35:
36: public Object apply3(Object arg1, Object arg2, Object arg3)
37: throws Throwable {
38: Object[] args = new Object[3];
39: args[0] = arg1;
40: args[1] = arg2;
41: args[2] = arg3;
42: return applyN(args);
43: }
44:
45: public Object apply4(Object arg1, Object arg2, Object arg3,
46: Object arg4) throws Throwable {
47: Object[] args = new Object[4];
48: args[0] = arg1;
49: args[1] = arg2;
50: args[2] = arg3;
51: args[3] = arg4;
52: return applyN(args);
53: }
54:
55: public abstract Object applyN(Object[] args) throws Throwable;
56: }
|