Class Generator

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Generator​(java.lang.String defaultTemplate, java.lang.String name)
      Constructs the part of the generator.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void fillTemplate​(Template template)
      Sets the variables used in the template file.
      void generate()
      Generates the output file from the current AST.
      java.lang.String getClassName()
      Returns the class name (without the package name).
      java.lang.String getPackageName()
      Returns the package name.
      void setOutputDirectory​(java.lang.String outputDirectory)
      Sets the directory to write the generated file to.
      void setTemplateFile​(java.lang.String templateFile)
      Sets the template file to use instead of the default one.
      • Methods inherited from class java.lang.Object

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

      • Generator

        protected Generator​(java.lang.String defaultTemplate,
                            java.lang.String name)
        Constructs the part of the generator.
        Parameters:
        defaultTemplate - the path in the JAR file to the template used if no specific template is configured
        name - the name of the package + class
    • Method Detail

      • getPackageName

        public java.lang.String getPackageName()
        Returns the package name.
        Returns:
        the package name (using the dot notation)
      • getClassName

        public java.lang.String getClassName()
        Returns the class name (without the package name).
        Returns:
        the class name
      • setTemplateFile

        public void setTemplateFile​(java.lang.String templateFile)
        Sets the template file to use instead of the default one.
        Parameters:
        templateFile - the template path
      • setOutputDirectory

        public void setOutputDirectory​(java.lang.String outputDirectory)
        Sets the directory to write the generated file to.
        Parameters:
        outputDirectory - the output directory name
      • generate

        public void generate()
                      throws java.io.IOException,
                             SemanticException
        Generates the output file from the current AST.
        Throws:
        java.io.IOException - when the file can not be read / written
        SemanticException - when there is a semantic error in the input file
      • fillTemplate

        protected void fillTemplate​(Template template)
                             throws SemanticException
        Sets the variables used in the template file.
        Parameters:
        template - the template object
        Throws:
        SemanticException - on template filling / code generation failure