public class CodeGenerator
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private Configuration |
configuration
Configuration of generator.
|
private static java.lang.String |
FSM_CLASS_SUFFIX
Suffix of generated state machine class name.
|
private static FsmLogger |
logger
The logger.
|
private QfsmMachine |
machine
Qfsm state machine.
|
private CodeGeneratorParameters |
parameters
Program parameters.
|
private static java.lang.String |
PROCESSOR_CLASS_SUFFIX
Suffix of generated processor class name.
|
private QfsmProject |
qfsm
Qfsm data file.
|
private static boolean |
systemExitCallAllowed
Helper flag for unit tests to disable System.exit() calls.
|
Modifier | Constructor and Description |
---|---|
private |
CodeGenerator(CodeGeneratorParameters parameters)
Create the object.
|
Modifier and Type | Method and Description |
---|---|
private static java.lang.String |
formatPrompt(java.lang.String[] args) |
private void |
generateProcessor() |
private void |
genFsmFile()
Generate the state machine file.
|
private java.lang.String |
genGlobalStateListeners()
Generate the global state listener.
|
private java.lang.String |
genGlobalTransitionListener()
Generate the global transition listener.
|
private java.lang.String |
genStateDeclarations()
Generate declarations of states.
|
private java.lang.String |
genStateInitializations()
Generate initializations of states.
|
private java.lang.String |
genStateListeners()
Generate the state listeners.
|
private java.lang.String |
genTransitionDeclarations()
Generate declarations of transitions.
|
private java.lang.String |
genTransitionInitializations()
Generate initializations of transitions.
|
private java.lang.String |
genTransitionListeners()
Generate the transition listeners.
|
private java.lang.String |
identifier(QfsmState state)
Generate a Java identifier from a state.
|
private java.lang.String |
identifier(QfsmTransition transition)
Generate a Java identifier from a transition.
|
private java.lang.String |
identifier(java.lang.String str)
Generate a Java identifier from a string.
|
private static java.lang.String |
loadTemplate(java.lang.String name)
Load a template for the code generation.
|
static void |
main(java.lang.String[] args)
The program enter.
|
(package private) static void |
setSystemExitCallAllowed(boolean systemExitCallAllowed)
Enable/disable System.exit() calls.
|
private static void |
writeFile(java.io.File file,
java.lang.String content,
boolean force)
Write a text file.
|
private static final FsmLogger logger
private static boolean systemExitCallAllowed
private static final java.lang.String FSM_CLASS_SUFFIX
private static final java.lang.String PROCESSOR_CLASS_SUFFIX
private final CodeGeneratorParameters parameters
private final Configuration configuration
private final QfsmProject qfsm
private final QfsmMachine machine
private CodeGenerator(CodeGeneratorParameters parameters) throws QfsmException
parameters
- program argumentsQfsmException
private void genFsmFile() throws QfsmException
QfsmException
- if something failsprivate void generateProcessor() throws QfsmException
QfsmException
private java.lang.String genStateDeclarations() throws QfsmException
QfsmException
- if something failsprivate java.lang.String genStateInitializations() throws QfsmException
QfsmException
- if something failsprivate java.lang.String genStateListeners() throws QfsmException
QfsmException
- if something failsprivate java.lang.String genGlobalStateListeners() throws QfsmException
QfsmException
- if something failsprivate java.lang.String genTransitionDeclarations() throws QfsmException
QfsmException
- if something failsprivate java.lang.String genTransitionInitializations() throws QfsmException
QfsmException
- if something failsprivate java.lang.String genTransitionListeners() throws QfsmException
QfsmException
- if something failsprivate java.lang.String genGlobalTransitionListener() throws QfsmException
QfsmException
- if something failsprivate static void writeFile(java.io.File file, java.lang.String content, boolean force) throws QfsmException
file
- the destination filecontent
- the text content of the fileforce
- rewrite existing fileQfsmException
- if something failsprivate java.lang.String identifier(java.lang.String str)
str
- the input stringprivate java.lang.String identifier(QfsmState state)
state
- the stateprivate java.lang.String identifier(QfsmTransition transition)
transition
- the transitionprivate static java.lang.String loadTemplate(java.lang.String name) throws QfsmException
name
- the path in file system or in jar packageQfsmException
- if something failsprivate static java.lang.String formatPrompt(java.lang.String[] args)
static void setSystemExitCallAllowed(boolean systemExitCallAllowed)
systemExitCallAllowed
- enable flagpublic static void main(java.lang.String[] args)
args
- the input argumentsCodeGeneratorParameters
Copyright 2013 Michal Turek, AnotherFSM.