KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > kawa > standard > make


1 package kawa.standard;
2 import kawa.lang.*;
3 import gnu.mapping.*;
4 import gnu.expr.*;
5
6 public class make extends ProcedureN
7 {
8   public int numArgs() { return 0xFFFFF001; } // minimum 1 argument
9

10   public Object JavaDoc applyN (Object JavaDoc[] args)
11   {
12     int nargs = args.length;
13     if (nargs == 0)
14       throw new WrongArguments(this, nargs);
15     Object JavaDoc arg_0 = args[0];
16     Class JavaDoc clas;
17     if (arg_0 instanceof Class JavaDoc)
18       clas = (Class JavaDoc) arg_0;
19     else if (arg_0 instanceof gnu.bytecode.ClassType)
20       clas = ((gnu.bytecode.ClassType) arg_0).getReflectClass();
21     else
22       clas = null;
23     if (clas == null)
24       throw new WrongType(this, 1, arg_0, "class");
25     Object JavaDoc result;
26     try
27       {
28     result = clas.newInstance();
29       }
30     catch (Exception JavaDoc ex)
31       {
32     throw new WrappedException(ex);
33       }
34     for (int i = 1; i < nargs; )
35       {
36     Keyword key = (Keyword) args[i++];
37     Object JavaDoc arg = args[i++];
38     Record.set1(arg, key.getName(), result);
39       }
40     return result;
41   }
42 }
43
Popular Tags