<commit_before>
p. 

h2(#codegen_java_code_generator). Java code generator

h3(#codegen_java_code_generator_features). Java code generator features

==<!-- Start sgen_feature_naming -->==

h4(#codegen_java_naming_feature). Naming feature

The *Naming* feature allows the configuration of package names for the generated classes (and interfaces) as well as a prefix and/or a suffix for their names.

It is an _optional_ feature and has the following parameters:

* _basePackage_ (String, required): Package name for the generated Java classes
* _implementationSuffix_ (String, optional): Name suffix for the implementing classes

==<div class="example">==

Example:

bc. feature Naming {
    basePackage = "org.ourproject.sct"
    implementationSuffix = "Impl"
}

==</div>==

==<!-- End sgen_feature_naming -->==



==<!-- Start sgen_feature_synchronizedwrapper -->==

h4(#codegen_java_synchronizedwrapper_feature). SynchronizedWrapper feature

The *SynchronizedWrapper* feature generates a synchronized wrapper for the state machine. This is an additional Java class providing thread-safe access to the generated state machine implementation. As the wrapper adds thread safety any number of client threads may call the state machine.

It is an _optional_ feature and has the following parameters:

* _namePrefix_ (String, optional): Name prefix for the generated wrapper class
* _nameSuffix_ (String, optional): Name suffix for the generated wrapper class

==<div class="example">==

Example:

bc. feature SynchronizedWrapper {
    namePrefix = "Synchronized"
    nameSuffix = "Wrapper"
}

==</div>==

==<!-- End sgen_feature_synchronizedwrapper -->==



==<!-- Start sgen_feature_runnablewrapper -->==

h4(#codegen_java_runnablewrapper_feature). RunnableWrapper feature

The *RunnableWrapper* feature generates a runnable wrapper for the state machine. This is an additional Java class providing a thread-safe wrapper for the generated state machine implementation. In addition to the specific state machine interface it implements the _Runnable_ interface and can be executed in a thread. It implements an event queue and event-driven execution semantics. As the wrapper adds thread safety any number of client threads may call the state machine.

It is an _optional_ feature and has the following parameters:

* _namePrefix_ (String, optional): Name prefix for the generated wrapper class
* _nameSuffix_ (String, optional): Name suffix for the generated wrapper class

==<div class="example">==

Example:

bc. feature RunnableWrapper {
    namePrefix = "Runnable"
    nameSuffix = "Wrapper"
}

==</div>==

==<!-- End sgen_feature_runnablewrapper -->==



==<!-- Start sgen_feature_generalfeatures -->==

h4(#codegen_java_generalfeatures). GeneralFeatures feature

The *GeneralFeatures* feature allows to configure additional services to be generated along with the state machine. Per default, all parameters are _false_, meaning to disable the corresponding features, respectively.

*GeneralFeatures* is an _optional_ feature and has the following parameters:

* _InterfaceObserverSupport_ (Boolean, optional): Enables/disables the generation of listener interfaces for the state machine.
* _RuntimeService_ (Boolean, optional): Enables/disables the generation of a runtime service that triggers the run cycle of a cycle-based state machine.
* _TimerService_ (Boolean, optional): Enables/disables the generation of a timer service implementation using _java.util.Timer_.

==<div class="example">==

Example:

bc. feature GeneralFeatures {
    InterfaceObserverSupport = true
    RuntimeService = true
    TimerService = true
}

==</div>==

==<!-- End sgen_feature_generalfeatures -->==




h3(#codegen_java_specification_of_java_code). Specification of Java code

In order to describe the API specifications of the code generated by the YAKINDU Java generator, the explanations below are using the _Traffic Light_ sample state machine, see "figure &quot;The _Traffic Light_ sample statechart model&quot;":#codegen_java_fig_the_traffic_light_sample_statechart_model. It models a pedestrian crossing with push-button operated traffic lights ("pelican crossing").

p(#codegen_java_fig_the_traffic_light_sample_statechart_model). 
!(full)images/docu_TrafficLight.png(The _Traffic Light_ sample statechart model)!

p=. The _Traffic Light_ sample statechart model

###. You can find the Java sample project _"Traffic Light (Java)":https://github.com/Yakindu/examples/tree/master/traffic_light_java_ in the "YAKINDU Statechart Tools examples repository":https://github.com/Yakindu/examples. The Java example contains statechart, SGen model, graphical widgets, and some glue code to connect the generated code with the widgets. The graphical widgets are based on SWT.

###. To execute the Java example, run the file _CrossingDemoCycleBased.java_ as "Java Application" from the Eclipse _Run As_ context menu.



h4(#codegen_java_generated_code_files). Generated code files

Generally you will find generated code at the places specified in the SGen model, see "section &quot;Outlet&quot;":../user-guide/code_generation_intro.html#codegen_outlet_feature for details.

In the case of the traffic light example, you will find the generated code in the _src-gen_ folder.

The package _org.yakindu.sct.examples.trafficlight.cyclebased_ contains the general state machine interfaces and classes. They are needed by each particular state machine and are independend from concrete ones.



h4(#codegen_java_the_state_machine_interface). The state machine interface

Each generated state machine implements the _IStatemachine_ interface:
<commit_msg>added docu part for tracing<commit_after>
p. 

h2(#codegen_java_code_generator). Java code generator

h3(#codegen_java_code_generator_features). Java code generator features

==<!-- Start sgen_feature_naming -->==

h4(#codegen_java_naming_feature). Naming feature

The *Naming* feature allows the configuration of package names for the generated classes (and interfaces) as well as a prefix and/or a suffix for their names.

It is an _optional_ feature and has the following parameters:

* _basePackage_ (String, required): Package name for the generated Java classes
* _implementationSuffix_ (String, optional): Name suffix for the implementing classes

==<div class="example">==

Example:

bc. feature Naming {
    basePackage = "org.ourproject.sct"
    implementationSuffix = "Impl"
}

==</div>==

==<!-- End sgen_feature_naming -->==



==<!-- Start sgen_feature_synchronizedwrapper -->==

h4(#codegen_java_synchronizedwrapper_feature). SynchronizedWrapper feature

The *SynchronizedWrapper* feature generates a synchronized wrapper for the state machine. This is an additional Java class providing thread-safe access to the generated state machine implementation. As the wrapper adds thread safety any number of client threads may call the state machine.

It is an _optional_ feature and has the following parameters:

* _namePrefix_ (String, optional): Name prefix for the generated wrapper class
* _nameSuffix_ (String, optional): Name suffix for the generated wrapper class

==<div class="example">==

Example:

bc. feature SynchronizedWrapper {
    namePrefix = "Synchronized"
    nameSuffix = "Wrapper"
}

==</div>==

==<!-- End sgen_feature_synchronizedwrapper -->==



==<!-- Start sgen_feature_runnablewrapper -->==

h4(#codegen_java_runnablewrapper_feature). RunnableWrapper feature

The *RunnableWrapper* feature generates a runnable wrapper for the state machine. This is an additional Java class providing a thread-safe wrapper for the generated state machine implementation. In addition to the specific state machine interface it implements the _Runnable_ interface and can be executed in a thread. It implements an event queue and event-driven execution semantics. As the wrapper adds thread safety any number of client threads may call the state machine.

It is an _optional_ feature and has the following parameters:

* _namePrefix_ (String, optional): Name prefix for the generated wrapper class
* _nameSuffix_ (String, optional): Name suffix for the generated wrapper class

==<div class="example">==

Example:

bc. feature RunnableWrapper {
    namePrefix = "Runnable"
    nameSuffix = "Wrapper"
}

==</div>==

==<!-- End sgen_feature_runnablewrapper -->==



==<!-- Start sgen_feature_generalfeatures -->==

h4(#codegen_java_generalfeatures). GeneralFeatures feature

The *GeneralFeatures* feature allows to configure additional services to be generated along with the state machine. Per default, all parameters are _false_, meaning to disable the corresponding features, respectively.

*GeneralFeatures* is an _optional_ feature and has the following parameters:

* _InterfaceObserverSupport_ (Boolean, optional): Enables/disables the generation of listener interfaces for the state machine.
* _RuntimeService_ (Boolean, optional): Enables/disables the generation of a runtime service that triggers the run cycle of a cycle-based state machine.
* _TimerService_ (Boolean, optional): Enables/disables the generation of a timer service implementation using _java.util.Timer_.

==<div class="example">==

Example:

bc. feature GeneralFeatures {
    InterfaceObserverSupport = true
    RuntimeService = true
    TimerService = true
}

==</div>==

==<!-- End sgen_feature_generalfeatures -->==


==<!-- Start sgen_feature_tracing -->==

h4(#codegen_c_tracing_feature). Tracing feature

The *Tracing* feature enables the generation of tracing callback functions:

* _enterState_ (boolean, optional): Specifies whether to generate a callback function that is used to notify about state-entering events.
* _exitState_ (boolean, optional): Specifies whether to generate a callback that is used to notify about state-exiting events.

==<div class="example">==

Example:

bc. feature Tracing {
    enterState = true
    exitState  = true
}

==</div>==

==<!-- End sgen_feature_tracing -->==


h3(#codegen_java_specification_of_java_code). Specification of Java code

In order to describe the API specifications of the code generated by the YAKINDU Java generator, the explanations below are using the _Traffic Light_ sample state machine, see "figure &quot;The _Traffic Light_ sample statechart model&quot;":#codegen_java_fig_the_traffic_light_sample_statechart_model. It models a pedestrian crossing with push-button operated traffic lights ("pelican crossing").

p(#codegen_java_fig_the_traffic_light_sample_statechart_model). 
!(full)images/docu_TrafficLight.png(The _Traffic Light_ sample statechart model)!

p=. The _Traffic Light_ sample statechart model

###. You can find the Java sample project _"Traffic Light (Java)":https://github.com/Yakindu/examples/tree/master/traffic_light_java_ in the "YAKINDU Statechart Tools examples repository":https://github.com/Yakindu/examples. The Java example contains statechart, SGen model, graphical widgets, and some glue code to connect the generated code with the widgets. The graphical widgets are based on SWT.

###. To execute the Java example, run the file _CrossingDemoCycleBased.java_ as "Java Application" from the Eclipse _Run As_ context menu.



h4(#codegen_java_generated_code_files). Generated code files

Generally you will find generated code at the places specified in the SGen model, see "section &quot;Outlet&quot;":../user-guide/code_generation_intro.html#codegen_outlet_feature for details.

In the case of the traffic light example, you will find the generated code in the _src-gen_ folder.

The package _org.yakindu.sct.examples.trafficlight.cyclebased_ contains the general state machine interfaces and classes. They are needed by each particular state machine and are independend from concrete ones.



h4(#codegen_java_the_state_machine_interface). The state machine interface

Each generated state machine implements the _IStatemachine_ interface:

{'fraction_non_alphanumeric': 0.0760549145119178, 'fraction_numerical': 0.0016002695190768972, 'mean_word_length': 5.377013963480129, 'pattern_counts': {'":': 8, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5530160', 'n_tokens_mistral': 3183, 'n_tokens_neox': 3089, 'n_words': 1283}