Package org.nuiton.eugene.models.state
Class StateModelGenerator
- java.lang.Object
-
- org.nuiton.eugene.Template<M>
-
- org.nuiton.eugene.AbstractGenerator<StateModel>
-
- org.nuiton.eugene.models.state.StateModelGenerator
-
- All Implemented Interfaces:
TemplateConfiguration
public class StateModelGenerator extends AbstractGenerator<StateModel>
StateModelGenerator. Pour utiliser ce type de générateur, il faut implanter au moins une des méthodes generateFrom... et le getFilenameFor... associé si l'on souhaite un nom de fichier convenable. Si dans une méthode generateFrom... on utilise pas le writer (output) alors aucun fichier n'est généré. Le nom de l'argument writer doit absolument etre output et pas autre chose si vous souhaitez utiliser le processeurorg.nuiton.processor.filters.GeneratorTemplatesFilter
pour vous s'implifier l'écriture des templates.- Author:
- chatellier
-
-
Field Summary
-
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 StateModelGenerator()
Empty constructorStateModelGenerator(AbstractGenerator<StateModel> parent)
Constructor with parent generator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
applyTemplate(StateModel stateModel, File destDir)
Par défaut, appelgenerateFromModel(MonitorWriter, StateModel)
pour le model etgenerateFromState(Writer, StateModelState)
pour tous les etats du modele.protected boolean
canGenerateElement(StateModelStateChart chart)
Test if given element can be generated.protected void
generateFromModel(MonitorWriter monitorOut, StateModel stateModel)
Generate model codevoid
generateFromState(Writer monitorOut, StateModelState state)
Generate a state codeprotected String
getFilenameFromModel(StateModel stateModel)
Return filename from modelString
getFilenameFromState(StateModelState state, String packageName)
Return filename from state-
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
-
-
-
-
Constructor Detail
-
StateModelGenerator
public StateModelGenerator()
Empty constructor
-
StateModelGenerator
public StateModelGenerator(AbstractGenerator<StateModel> parent)
Constructor with parent generator.- Parameters:
parent
- parent generator
-
-
Method Detail
-
applyTemplate
public void applyTemplate(StateModel stateModel, File destDir) throws IOException
Par défaut, appelgenerateFromModel(MonitorWriter, StateModel)
pour le model etgenerateFromState(Writer, StateModelState)
pour tous les etats du modele.- Specified by:
applyTemplate
in classTemplate<StateModel>
- Parameters:
stateModel
- Le modele d'étatdestDir
- le dossier de destination- Throws:
IOException
- if any IO problem while applying templtate
-
canGenerateElement
protected boolean canGenerateElement(StateModelStateChart chart)
Test if given element can be generated.- Parameters:
chart
- chart to test- Returns:
- generation allowed
-
generateFromModel
protected void generateFromModel(MonitorWriter monitorOut, StateModel stateModel)
Generate model code- Parameters:
monitorOut
- the output writerstateModel
- the model
-
getFilenameFromModel
protected String getFilenameFromModel(StateModel stateModel)
Return filename from model- Parameters:
stateModel
- the model- Returns:
- model file name
-
getFilenameFromState
public String getFilenameFromState(StateModelState state, String packageName)
Return filename from state- Parameters:
state
- the statepackageName
- the package name- Returns:
- the filename
-
generateFromState
public void generateFromState(Writer monitorOut, StateModelState state) throws IOException
Generate a state code- Parameters:
monitorOut
- the output writerstate
- the state- Throws:
IOException
- if any IO problem while generating
-
-