List of Listings – Code Generation in Action

List of Listings

Chapter 3. Code generation tools

Listing 3.1. Example code for parsing SQL

Listing 3.2. Example code for parsing PostgreSQL

Listing 3.3. Example code for parsing C

Listing 3.4. Example code for parsing C++

Listing 3.5. Example code for parsing Java

Chapter 4. Building simple generators

Listing 4.1. Code munger 1, first variant: reading from a single file

Listing 4.2. Code munger 1, second variant: parsing a directory

Listing 4.3. Code munger 1, third variant: reading from standard input

Listing 4.4. Code munger 1, fourth variant: reading from a file using the language parser toolkit

Listing 4.5. Code munger 2: Looks for specific comments in a C file

Listing 4.6. Code munger 3: Converts a C file to HTML

Listing 4.7. Code munger 4: Transforms an XML file

Listing 4.8. Listing 4.8 Code munger 5: Creates C constants from a CSV file

Listing 4.9. Template for code munger 5

Listing 4.10. Code munger 6: Creates Java base classes for data storage

Listing 4.11. Base.template.java

Listing 4.12. Listing 4.12 Inline-code expander: Printf maker

Listing 4.13. Mixed-code generator 1: building printfs

Listing 4.14. Partial-class generator: building structure classes from a CSV file

Listing 4.15. The tier generator: building structure classes from XML

Listing 4.16. field_class.template.java

Chapter 5. Generating user interfaces

Listing 5.1. Listuibuilder.rb

Listing 5.2. table_page

Listing 5.3. Form template code

Listing 5.4. edit_form

Chapter 6. Generating documentation

Listing 6.1. Example of Java using JavaDoc structured documentation standard

Listing 6.2. docgen.rb

Listing 6.3. table_page.html.template

Chapter 7. Generating unit tests

Listing 7.1. testgen.rb

Chapter 8. Embedding SQL with generators

Listing 8.1. psqlgen.rb

Listing 8.2. The FlexibleSQL class

Chapter 9. Handling data

Listing 9.1. csvgen.rb

Listing 9.2. Reader.java.template

Listing 9.3. Reader.java.template output

Chapter 11. Generating web services layers

Listing 11.1. Test.java

Listing 11.2. rpcgen.rb

Listing 11.3. HandlerMethod.java

Listing 11.4. Handler.java.template

Listing 11.5. TestHandler.java output

Listing 11.6. StubsMethod.java

Listing 11.7. The Stubs.java.template

Listing 11.8. TestStubs.java output

Listing 11.9. Server.java

Listing 11.10. Client.java

Chapter 12. Generating business logic

Listing 12.1. Test1.java

Listing 12.2. Test1.java after generation

Listing 12.3. bdgen.rb

Chapter 13. More generator ideas

Listing 13.1. lookup_function_example.c

Listing 13.2. lookup_table_example.c

Appendix C. EJBGen code and templates

Listing C.1. ejbgenRead.rb

Listing C.2. ejbgenDefs.rb

Listing C.3. ejbgen.rb

Listing C.4. Entity.java.template

Listing C.5. EntityBean.java.template

Listing C.6. Add.jsp.template

Listing C.7. jboss.xml.template

Listing C.8. tables.sql.template