Class JavaGenerator
java.lang.Object
edu.nps.moves.dis7.source.generator.pdus.Generator
edu.nps.moves.dis7.source.generator.pdus.JavaGenerator
Given the input object, something of an abstract syntax tree, this generates a source code file in the Java language.
It has ivars, getters, setters, and serialization/deserialization methods.
Fully implemented.
- Author:
- DMcG
-
Field Summary
Fields inherited from class edu.nps.moves.dis7.source.generator.pdus.Generator
classDescriptions, directory, languageProperties
-
Constructor Summary
ConstructorsConstructorDescriptionJavaGenerator(Map<String,GeneratedClass> pClassDescriptions, Properties pJavaProperties)
Constructor -
Method Summary
Modifier and TypeMethodDescriptioninitialCap(String aString)
returns a string with the first letter capitalized.initialLower(String aString)
returns a string with the first letter lower case.void
Generate the classes and write them to a directoryvoid
writeEqualityImplMethod(PrintWriter pw, GeneratedClass aClass)
write equalsImpl(...) method to this class to parent or subclassesvoid
writeEqualityMethod(PrintWriter pw, GeneratedClass aClass)
Write the code for an equality operator.void
writeGetMarshalledSizeMethod(PrintWriter printWriter, GeneratedClass aClass)
Produce custom getMarshalledSize() methodvoid
writeToStringMethod(PrintWriter pw, GeneratedClass aClass)
Build the toString() method for this class, using the toString() methods of the fields of the objectMethods inherited from class edu.nps.moves.dis7.source.generator.pdus.Generator
createDirectory, getBitsToShift, getDirectory, setDirectory
-
Constructor Details
-
JavaGenerator
Constructor- Parameters:
pClassDescriptions
- String map of generated classespJavaProperties
- language properties
-
-
Method Details
-
writeClasses
public void writeClasses()Generate the classes and write them to a directory- Specified by:
writeClasses
in classGenerator
-
writeGetMarshalledSizeMethod
Produce custom getMarshalledSize() method- Parameters:
printWriter
- outputaClass
- input class
-
writeEqualityMethod
Write the code for an equality operator. This allows you to compare two objects for equality.The code should look like bool operator ==(const ClassName& rhs) return (_ivar1==rhs._ivar1 && _var2 == rhs._ivar2 ...)- Parameters:
pw
- PrintWriteraClass
- class of interest
-
writeEqualityImplMethod
write equalsImpl(...) method to this class to parent or subclasses- Parameters:
pw
- PrintWriteraClass
- class of interest
-
writeToStringMethod
Build the toString() method for this class, using the toString() methods of the fields of the object- Parameters:
pw
- PrintWriteraClass
- class of interest
-
initialCap
returns a string with the first letter capitalized.- Overrides:
initialCap
in classGenerator
- Parameters:
aString
- of interest- Returns:
- same string with first letter capitalized
-
initialLower
returns a string with the first letter lower case.- Overrides:
initialLower
in classGenerator
- Parameters:
aString
- of interest- Returns:
- same string with first letter lower case
-