org.glassfish.pfl.dynamic.codegen.impl
Class CodeGenerator

java.lang.Object
  extended by org.glassfish.pfl.dynamic.codegen.impl.CodeGenerator

public final class CodeGenerator
extends Object

Class 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.


Method Summary
static ClassGeneratorImpl defineClass(int modifiers, String name, Type superType, List<Type> impls)
          Define a ClassGeneratorImpl for a class.
static ClassGeneratorImpl defineInterface(int modifiers, String name, List<Type> impls)
          Define a ClassGeneratorImpl for an interface.
static byte[] generateBytecode(ClassGeneratorImpl cg, ClassLoader cl, ImportList imports, Properties options, PrintStream debugOutput)
          Convert the Java class or interface defined by ClassGeneratorImpl into an array of bytecodes.
static void generateSourceCode(PrintStream ps, ClassGeneratorImpl cg, ImportList imports, Properties options)
          Write a source code representation of the class or interface defined by cg to the PrintStream ps.
static void generateSourceCode(String sdir, ClassGeneratorImpl cg, ImportList imports, 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

defineClass

public static ClassGeneratorImpl defineClass(int modifiers,
                                             String name,
                                             Type superType,
                                             List<Type> impls)
Define a ClassGeneratorImpl for a class.


defineInterface

public static ClassGeneratorImpl defineInterface(int modifiers,
                                                 String name,
                                                 List<Type> impls)
Define a ClassGeneratorImpl for an interface.


generateBytecode

public static byte[] generateBytecode(ClassGeneratorImpl cg,
                                      ClassLoader cl,
                                      ImportList imports,
                                      Properties options,
                                      PrintStream debugOutput)
Convert the Java class or interface defined by ClassGeneratorImpl into an array of bytecodes.


generateSourceCode

public static void generateSourceCode(PrintStream ps,
                                      ClassGeneratorImpl cg,
                                      ImportList imports,
                                      Properties options)
                               throws IOException
Write a source code representation of the class or interface defined by cg to the PrintStream ps.

Throws:
IOException

generateSourceCode

public static void generateSourceCode(String sdir,
                                      ClassGeneratorImpl cg,
                                      ImportList imports,
                                      Properties options)
                               throws IOException
Write a source code representation of the class or interface defined by cg to a file in the SOURCE_GENERATION_DIRECTORY specified in options.

Throws:
IOException


Copyright © 2013 Oracle. All Rights Reserved.