KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > mapping > Procedure0or1


1 package gnu.mapping;
2
3 /**
4  * Abstract class for 0- or 1-argument Scheme procedures.
5  * Extensions must provide apply0 and apply1.
6  * @author Per Bothner
7  */

8
9 public abstract class Procedure0or1 extends Procedure
10 {
11
12   public Procedure0or1 ()
13   {
14     super();
15   }
16
17   public Procedure0or1 (String JavaDoc n)
18   {
19     super(n);
20   }
21
22   public int numArgs() { return 0x1000; }
23
24   public abstract Object JavaDoc apply0 () throws Throwable JavaDoc;
25
26   public abstract Object JavaDoc apply1 (Object JavaDoc arg1) throws Throwable JavaDoc;
27
28   public Object JavaDoc apply2 (Object JavaDoc arg1,Object JavaDoc arg2)
29   {
30     throw new WrongArguments(this, 2);
31   }
32
33   public Object JavaDoc apply3 (Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3)
34   {
35     throw new WrongArguments(this, 3);
36   }
37
38   public Object JavaDoc apply4 (Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3, Object JavaDoc arg4)
39   {
40     throw new WrongArguments(this, 4);
41   }
42
43   public Object JavaDoc applyN (Object JavaDoc[] args) throws Throwable JavaDoc
44   {
45     if (args.length == 0)
46       return apply0 ();
47     else if (args.length == 1)
48       return apply1 (args[0]);
49     else
50       throw new WrongArguments(this, args.length);
51   }
52 }
53
Popular Tags