Class Generator

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

public abstract class Generator extends Object
Abstract superclass for all the concrete language generators, such as java, 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
    • directory

      public String directory
      Directory in which to write the autogenerated source code
    • languageProperties

      protected Properties languageProperties
      properties for this programming language
  • Constructor Details

    • Generator

      public Generator(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.
    • createDirectory

      protected void createDirectory()
      Create the directory in which to put the generated source code files
    • getDirectory

      public String getDirectory()
      Directory in which to write the autogenerated source code
      Returns:
      the directory
    • setDirectory

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

      public String initialCap(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(ClassAttribute 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