KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > bsh > ClassGenerator


1 package bsh;
2
3 import bsh.Capabilities.Unavailable;
4 import java.lang.reflect.InvocationTargetException JavaDoc;
5
6 public abstract class ClassGenerator
7 {
8     private static ClassGenerator cg;
9
10     public static ClassGenerator getClassGenerator()
11         throws UtilEvalError
12     {
13         if ( cg == null )
14         {
15             try {
16                 Class JavaDoc clas = Class.forName( "bsh.ClassGeneratorImpl" );
17                 cg = (ClassGenerator)clas.newInstance();
18             } catch ( Exception JavaDoc e ) {
19                 throw new Unavailable("ClassGenerator unavailable: "+e);
20             }
21         }
22     
23         return cg;
24     }
25
26     /**
27         Parse the BSHBlock for the class definition and generate the class.
28     */

29     public abstract Class JavaDoc generateClass(
30         String JavaDoc name, Modifiers modifiers,
31         Class JavaDoc [] interfaces, Class JavaDoc superClass, BSHBlock block,
32         boolean isInterface, CallStack callstack, Interpreter interpreter
33     )
34         throws EvalError;
35
36     /**
37         Invoke a super.method() style superclass method on an object instance.
38         This is not a normal function of the Java reflection API and is
39         provided by generated class accessor methods.
40     */

41     public abstract Object JavaDoc invokeSuperclassMethod(
42         BshClassManager bcm, Object JavaDoc instance, String JavaDoc methodName, Object JavaDoc [] args
43     )
44         throws UtilEvalError, ReflectError, InvocationTargetException JavaDoc;
45
46     /**
47         Change the parent of the class instance namespace.
48         This is currently used for inner class support.
49         Note: This method will likely be removed in the future.
50     */

51     public abstract void setInstanceNameSpaceParent(
52         Object JavaDoc instance, String JavaDoc className, NameSpace parent );
53
54 }
55
Popular Tags