Class CodeGenerator


  • public final class CodeGenerator
    extends java.lang.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.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private CodeGenerator()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static ClassGeneratorImpl defineClass​(int modifiers, java.lang.String name, Type superType, java.util.List<Type> impls)
      Define a ClassGeneratorImpl for a class.
      static ClassGeneratorImpl defineInterface​(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 void generateSourceCode​(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 void generateSourceCode​(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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CodeGenerator

        private CodeGenerator()
    • 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.IOException
        Write 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.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:
        java.io.IOException