Class AbstractGenerator

java.lang.Object
edu.nps.moves.dis7.source.generator.pdus.AbstractGenerator
Direct Known Subclasses:
CppGenerator, CsharpGenerator, JavaGenerator, JavascriptGenerator, ObjcGenerator, PythonGenerator

public abstract class AbstractGenerator extends Object
Abstract superclass for all the concrete language generators such as Java, Python, C++, etc.
Author:
Don McGregor, Mike Bailey and Don Brutzman
  • Field Details

    • classDescriptions

      protected Map<String,GeneratedClass> classDescriptions
      Contains abstract descriptions of all the classes, key = name, value = object
    • generatedSourceDirectoryName

      public String generatedSourceDirectoryName
      Directory in which to write the autogenerated source code, relative to root of project
    • languageProperties

      protected Properties languageProperties
      properties for this programming language
  • Constructor Details

    • AbstractGenerator

      public AbstractGenerator(Map<String,GeneratedClass> pClassDescriptions, Properties pLanguageProperties)
      Constructor
      Parameters:
      pClassDescriptions - of interest
      pLanguageProperties - of interest
  • Method Details

    • writeClasses

      public abstract void writeClasses()
      Overridden by the subclasses to generate the code specific to that language.
    • createGeneratedSourceDirectory

      protected void createGeneratedSourceDirectory(boolean cleanFiles)
      Create the directory in which to put the generated source code files
      Parameters:
      cleanFiles - whether to clean out prior files, if any exist in that directory
    • getGeneratedSourceDirectoryName

      public String getGeneratedSourceDirectoryName()
      Directory in which to write the autogenerated source code
      Returns:
      the directory name
    • setGeneratedSourceDirectoryName

      public void setGeneratedSourceDirectoryName(String newDirectoryName)
      Directory in which to write the autogenerated source code
      Parameters:
      newDirectoryName - the directory to set
    • initialCapital

      public String initialCapital(String aString)
      returns a string with the first letter capitalized.
      Parameters:
      aString - of interest
      Returns:
      same string with first letter capitalized
    • initialLower

      public String initialLower(String aString)
      returns a string with the first letter lower case.
      Parameters:
      aString - of interest
      Returns:
      same string with first letter lower case
    • getBitsToShift

      protected int getBitsToShift(GeneratedClassAttribute anAttribute, String mask)
      This is ugly and brute force, but I don't see an easier way to do it. Given a mask (like 0xf0) we want to know how many bits to shift an integer when masking in a new value.
      Parameters:
      anAttribute - of interest
      mask - a character set for the mask value
      Returns:
      number of bits to shift