Class JavaGenerator
java.lang.Object
edu.nps.moves.dis7.source.generator.pdus.AbstractGenerator
edu.nps.moves.dis7.source.generator.pdus.JavaGenerator
This class autogenerates Java source code from XML PDU definitions, specifically
producing most source code needed for the opendis7-java distribution.
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
- See Also:
-
Field Summary
Fields inherited from class edu.nps.moves.dis7.source.generator.pdus.AbstractGenerator
classDescriptions, generatedSourceDirectoryName, languageProperties
-
Constructor Summary
ConstructorsConstructorDescriptionJavaGenerator
(Map<String, GeneratedClass> pClassDescriptions, Properties pJavaProperties) Constructor -
Method Summary
Modifier and TypeMethodDescriptioninitialCapital
(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.AbstractGenerator
createGeneratedSourceDirectory, getBitsToShift, getGeneratedSourceDirectoryName, setGeneratedSourceDirectoryName
-
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 classAbstractGenerator
-
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
-
initialCapital
returns a string with the first letter capitalized.- Overrides:
initialCapital
in classAbstractGenerator
- Parameters:
aString
- of interest- Returns:
- same string with first letter capitalized
-
initialLower
returns a string with the first letter lower case.- Overrides:
initialLower
in classAbstractGenerator
- Parameters:
aString
- of interest- Returns:
- same string with first letter lower case
-