List of Listings

 

Chapter 1. Why add Groovy to Java?

Listing 1.1. Sorting strings using the Collections.sort method

Listing 1.2. A Java class to sort strings

Listing 1.3. A Java class representing a task

Listing 1.4. A Spock test that checks each Java sorting method

Chapter 2. Groovy by example

Listing 2.1. Building a Swing UI 3D pie chart using Google Chart

Listing 2.2. Stadium.groovy: a POGO to hold stadium information

Listing 2.3. Geocoder.groovy, which uses the Google geocoder to compute lat and lng

Listing 2.4. populate_stadium_data.groovy

Listing 2.5. A portion of GetGameData, showing the attributes and initialization

Listing 2.6. boxscore.xml: the box score from game 4 of the 2007 World Series

Listing 2.7. The getGame method in GetGameData.groovy

Listing 2.8. The getGames method from GetGameData

Listing 2.9. GetGameDataTests.groovy: a JUnit 4 test case

Listing 2.10. GameServlet.groovy: a groovlet for Groovy Baseball

Chapter 3. Code-level integration

Listing 3.1. Finding all the available script engine factories

Listing 3.2. Using the ScriptEngine to execute a simple Groovy script

Listing 3.3. A JUnit test case to check the JSR 223 script engine results

Listing 3.4. JUnit 4 test class verifying results of calling Eval methods from Java

Listing 3.5. Using GroovyShell and Binding to invoke the Google geocoder

Listing 3.6. A Groovy class for geocoding

Chapter 4. Using Groovy features in Java

Listing 4.1. A simple POJO representing a person