Package org.nuiton.eugene.java
Class JavaGenerator
- java.lang.Object
-
- org.nuiton.eugene.Template<M>
-
- org.nuiton.eugene.AbstractGenerator<ObjectModel>
-
- org.nuiton.eugene.models.object.ObjectModelGenerator
-
- org.nuiton.eugene.java.JavaGenerator
-
- All Implemented Interfaces:
TemplateConfiguration
@Component(role=Template.class, hint="org.nuiton.eugene.java.JavaGenerator") public class JavaGenerator extends ObjectModelGenerator
JavaGenerator Stupid generation of an ObjectModel with Java classes and interfaces. Use of ImportsManager to get imports for a classifier (added in model in the JavaBuilder which construct the ObjectModel). The JavaGenerator is based on a ObjectModelGenerator : Java classes are represented by ObjectModelClass, ... Created: 22 oct. 200 9- Author:
- Florian Desbois - desbois@codelutin.com
-
-
Field Summary
Fields Modifier and Type Field Description protected int
innerLevel
protected String
prefix
-
Fields inherited from class org.nuiton.eugene.AbstractGenerator
parent
-
Fields inherited from class org.nuiton.eugene.Template
configuration, excludeTemplates, generatedPackages, model, resourcesHelper
-
Fields inherited from interface org.nuiton.eugene.TemplateConfiguration
PROP_CLASS_LOADER, PROP_DEFAULT_PACKAGE, PROP_ENCODING, PROP_EXCLUDE_TEMPLATES, PROP_GENERATED_PACKAGES, PROP_LAST_MODIFIED_SOURCE, PROP_OVERWRITE, PROP_VERBOSE, PROP_WRITER_REPORT
-
-
Constructor Summary
Constructors Constructor Description JavaGenerator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
generateAnnotations(Writer output, ObjectModelClassifier clazz, ObjectModelElement element)
protected void
generateAttributes(Writer output, ObjectModelClassifier clazz, Collection<ObjectModelAttribute> attributes)
Generate attributes from a collection of ObjectModelAttribute.protected void
generateBlock(Writer output, ObjectModelClassifier clazz, ObjectModelOperation op)
void
generateFromClass(Writer output, ObjectModelClass input)
Generate from all classes.void
generateFromEnum(Writer output, ObjectModelEnumeration input)
void
generateFromEnumeration(Writer output, ObjectModelEnumeration input)
void
generateFromInterface(Writer output, ObjectModelInterface input)
protected void
generateHeader(Writer output, ObjectModelClassifier classifier)
Generate Header for a classifier : Package, Documentation, Imports and Classifier signature.void
generateInnerClassifiers(Writer output, Collection<ObjectModelClassifier> innerClassifiers)
protected void
generateOperationDocumentation(Writer output, ObjectModelOperation op)
protected void
generateOperations(Writer output, ObjectModelClassifier clazz, Collection<ObjectModelOperation> operations)
Generate operations from a collection of ObjectModelOperationString
getFilenameForClass(ObjectModelClass clazz)
Par defaut cette methode retourne le QualifiedName convertie en chemin par exemple pour org.codelutin.Toto on aurait org/codelutin/TotoString
getFilenameForClassifier(ObjectModelClassifier clazz)
Par defaut cette methode retourne le QualifiedName convertie en chemin par exemple pour org.codelutin.Toto on aurait org/codelutin/TotoString
getFilenameForEnumeration(ObjectModelEnumeration enumeration)
String
getFilenameForInterface(ObjectModelInterface interfacez)
Par defaut cette methode retourne le QualifiedName convertie en chemin par exemple pour org.codelutin.Toto on aurait org/codelutin/Totoprotected void
preparePrefix(ObjectModelClassifier clazz)
-
Methods inherited from class org.nuiton.eugene.models.object.ObjectModelGenerator
applyTemplate, canGenerateElement, generateFromClassifier, generateFromElement, generateFromModel, getFilenameForModel, getFilenameForPackage
-
Methods inherited from class org.nuiton.eugene.AbstractGenerator
canGeneratePackage, getDestinationFile, getEncoding, getLastModifiedSource, getProperty, getProperty, getWriter, isNewerThanSource, isOverwrite, setParent, write
-
Methods inherited from class org.nuiton.eugene.Template
getClassLoader, getConfiguration, getExcludeTemplates, getGeneratedPackages, getModel, getOverwrite, getProperties, getResourcesHelper, getWriterReport, isVerbose, setConfiguration, setProperty
-
-
-
-
Field Detail
-
innerLevel
protected int innerLevel
-
prefix
protected String prefix
-
-
Method Detail
-
getFilenameForClass
public String getFilenameForClass(ObjectModelClass clazz)
Description copied from class:ObjectModelGenerator
Par defaut cette methode retourne le QualifiedName convertie en chemin par exemple pour org.codelutin.Toto on aurait org/codelutin/Toto- Overrides:
getFilenameForClass
in classObjectModelGenerator
- Parameters:
clazz
- la classe utilisee- Returns:
- le nom de la classe a generer
-
getFilenameForInterface
public String getFilenameForInterface(ObjectModelInterface interfacez)
Description copied from class:ObjectModelGenerator
Par defaut cette methode retourne le QualifiedName convertie en chemin par exemple pour org.codelutin.Toto on aurait org/codelutin/Toto- Overrides:
getFilenameForInterface
in classObjectModelGenerator
- Parameters:
interfacez
- l'interface utilisee- Returns:
- le nom du l'interface a generer
-
getFilenameForEnumeration
public String getFilenameForEnumeration(ObjectModelEnumeration enumeration)
- Overrides:
getFilenameForEnumeration
in classObjectModelGenerator
-
getFilenameForClassifier
public String getFilenameForClassifier(ObjectModelClassifier clazz)
Description copied from class:ObjectModelGenerator
Par defaut cette methode retourne le QualifiedName convertie en chemin par exemple pour org.codelutin.Toto on aurait org/codelutin/Toto- Overrides:
getFilenameForClassifier
in classObjectModelGenerator
- Parameters:
clazz
- le classifier utilisee- Returns:
- le nom du classifier a generer
-
generateFromClass
public void generateFromClass(Writer output, ObjectModelClass input) throws IOException
Generate from all classes.- Overrides:
generateFromClass
in classObjectModelGenerator
- Parameters:
output
- Writer for generating the java fileinput
- Class to manage for creating an output file- Throws:
IOException
- if any pb while writing file
-
generateFromInterface
public void generateFromInterface(Writer output, ObjectModelInterface input) throws IOException
- Overrides:
generateFromInterface
in classObjectModelGenerator
- Throws:
IOException
-
generateAnnotations
public void generateAnnotations(Writer output, ObjectModelClassifier clazz, ObjectModelElement element) throws IOException
- Throws:
IOException
-
generateFromEnumeration
public void generateFromEnumeration(Writer output, ObjectModelEnumeration input) throws IOException
- Overrides:
generateFromEnumeration
in classObjectModelGenerator
- Throws:
IOException
-
generateFromEnum
public void generateFromEnum(Writer output, ObjectModelEnumeration input) throws IOException
- Overrides:
generateFromEnum
in classObjectModelGenerator
- Throws:
IOException
-
generateInnerClassifiers
public void generateInnerClassifiers(Writer output, Collection<ObjectModelClassifier> innerClassifiers) throws IOException
- Throws:
IOException
-
preparePrefix
protected void preparePrefix(ObjectModelClassifier clazz)
-
generateHeader
protected void generateHeader(Writer output, ObjectModelClassifier classifier) throws IOException
Generate Header for a classifier : Package, Documentation, Imports and Classifier signature.- Parameters:
output
- Writer for generating the java fileclassifier
- Classifier for generate header- Throws:
IOException
- if any pb while writing file
-
generateAttributes
protected void generateAttributes(Writer output, ObjectModelClassifier clazz, Collection<ObjectModelAttribute> attributes) throws IOException
Generate attributes from a collection of ObjectModelAttribute.- Parameters:
output
- Writer for generating the java fileclazz
- classifier in generationattributes
- Collection of ObjectModelAttribute to generate- Throws:
IOException
- if any pb while writing file
-
generateOperations
protected void generateOperations(Writer output, ObjectModelClassifier clazz, Collection<ObjectModelOperation> operations) throws IOException
Generate operations from a collection of ObjectModelOperation- Parameters:
output
- Writer for generating the java fileclazz
- classifier in generationoperations
- Collection of ObjectModelOperation to generate- Throws:
IOException
- if any pb while writing file
-
generateOperationDocumentation
protected void generateOperationDocumentation(Writer output, ObjectModelOperation op) throws IOException
- Throws:
IOException
-
generateBlock
protected void generateBlock(Writer output, ObjectModelClassifier clazz, ObjectModelOperation op) throws IOException
- Throws:
IOException
-
-