Class CodeGenerator
- java.lang.Object
-
- org.glassfish.pfl.dynamic.codegen.impl.CodeGenerator
-
public final class CodeGenerator extends java.lang.ObjectClass used to define classes and interfaces, and to generator source or byte code from the resulting definitions. This is the factory for the codegen framework.
-
-
Constructor Summary
Constructors Modifier Constructor Description privateCodeGenerator()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ClassGeneratorImpldefineClass(int modifiers, java.lang.String name, Type superType, java.util.List<Type> impls)Define a ClassGeneratorImpl for a class.static ClassGeneratorImpldefineInterface(int modifiers, java.lang.String name, java.util.List<Type> impls)Define a ClassGeneratorImpl for an interface.static byte[]generateBytecode(ClassGeneratorImpl cg, java.lang.ClassLoader cl, ImportList imports, java.util.Properties options, java.io.PrintStream debugOutput)Convert the Java class or interface defined by ClassGeneratorImpl into an array of bytecodes.static voidgenerateSourceCode(java.io.PrintStream ps, ClassGeneratorImpl cg, ImportList imports, java.util.Properties options)Write a source code representation of the class or interface defined by cg to the PrintStream ps.static voidgenerateSourceCode(java.lang.String sdir, ClassGeneratorImpl cg, ImportList imports, java.util.Properties options)Write a source code representation of the class or interface defined by cg to a file in the SOURCE_GENERATION_DIRECTORY specified in options.
-
-
-
Method Detail
-
defineClass
public static ClassGeneratorImpl defineClass(int modifiers, java.lang.String name, Type superType, java.util.List<Type> impls)
Define a ClassGeneratorImpl for a class.
-
defineInterface
public static ClassGeneratorImpl defineInterface(int modifiers, java.lang.String name, java.util.List<Type> impls)
Define a ClassGeneratorImpl for an interface.
-
generateBytecode
public static byte[] generateBytecode(ClassGeneratorImpl cg, java.lang.ClassLoader cl, ImportList imports, java.util.Properties options, java.io.PrintStream debugOutput)
Convert the Java class or interface defined by ClassGeneratorImpl into an array of bytecodes.
-
generateSourceCode
public static void generateSourceCode(java.io.PrintStream ps, ClassGeneratorImpl cg, ImportList imports, java.util.Properties options) throws java.io.IOExceptionWrite a source code representation of the class or interface defined by cg to the PrintStream ps.- Throws:
java.io.IOException
-
generateSourceCode
public static void generateSourceCode(java.lang.String sdir, ClassGeneratorImpl cg, ImportList imports, java.util.Properties options) throws java.io.IOExceptionWrite a source code representation of the class or interface defined by cg to a file in the SOURCE_GENERATION_DIRECTORY specified in options.- Throws:
java.io.IOException
-
-