
Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


By: Ken Kousen
Publisher: O'Reilly Media, Inc.
Pub. Date: November 14, 2011
Running Time: 2 hours 38 minutes 2 seconds
Subscriber Rating: ![]()
![]()
![]()
![]()
[2 Ratings] Subscriber Reviews
The goal of this screencast is to introduce the Groovy programming language to developers. Groovy is the hottest of the new family of dynamic languages that run on the Java Virtual Machine, and it combines intuitive syntax with many of the advanced features, like closures and metaprogramming, found in modern languages. Since Groovy is very similar in syntax to Java, existing Java developers will find it particularly easy to learn. Any developer familiar with object-oriented programming will find it useful, however.
Average Rating: ![]()
![]()
![]()
![]()
Based on 2 Ratings
"Good introduction to Groovy" - by stivlo on 08-FEB-2012
Reviewer Rating: ![]()
![]()
![]()
![]()
![]()
Don't expect to learn the ins and outs of Groovy from this short course, but it's a good introduction. For instance Grails is not covered. I am glad that it stimulated my appetite to learn more about Groovy. Now I'm off to read a Groovy book.
A few of the videos end before the last sentence could be heard.
Report as Inappropriate
Top Level Categories:
Information Technology & Software Development
Sub-Categories:
Information Technology & Software Development > Programming
Programming > Java
Chapter/Selection | Time | |
|---|---|---|
Description: See how easy it is to set-up an IDE to use Groovy and then dive right in. Most IDEs now support Groovy to varying degrees. We'll use NetBeans version 6.5, but will talk about both the Eclipse plugin and the best commercial alternative, IntelliJ's IDEA. We'll also speculate on future improvements in this area. Closed Captioning: Unavailable Mobile-Friendly Format: Available on m.safaribooksonline.com Example Files: Not Applicable | 00:06:33 | |
Description: Maps and arrays are native data structures in Groovy. Learn how simple it is to populate them and process their contents. Groovy uses lists and maps as native data structures. In this section we illustrate how easy it is to define and populate list and map instances and process their contents. Closed Captioning: Unavailable Mobile-Friendly Format: Available on m.safaribooksonline.com Example Files: Not Applicable | 00:06:59 | |
Using Simple Regular Expressions Description: Use the "slashy" syntax to create very simple regular expressions that can sort data. Java has had regular expression support since version 1.4. Groovy greatly enhances the regex capabilities, and introduces a "slashy" syntax that makes defining regular expressions much easier. Here we introduce that syntax to define a simple regular expression that we then use to sort data. Closed Captioning: Unavailable Mobile-Friendly Format: Available on m.safaribooksonline.com Example Files: Not Applicable | 00:06:24 | |
Description: Process the result lists and maps to build a URL string and submit it to Google Chart. Groovy not only includes lists and maps as native data structures, it also defines special operations and operators for collection data types. Here we illustrate methods like each() and collect() to transform our data into a query string to send to Google Chart. Closed Captioning: Unavailable Mobile-Friendly Format: Available on m.safaribooksonline.com Example Files: Not Applicable | 00:10:52 | |
Strings and Parameterized Strings Description: Groovy introduces parameterized strings (GStrings) that allow data to be substituted into results. Use parameterized strings to build an image tag of results, which can be included in any HTML page. Groovy has a special type of String that allows data to be substituted into it. Here we use parameterized strings to build an image tag with our results, which can be included in any HTML page. Closed Captioning: Unavailable Mobile-Friendly Format: Available on m.safaribooksonline.com Example Files: Not Applicable | 00:07:42 | |
Description: Switch from using hard-coded course titles to reading them from a database. To simplify database access, Groovy introduces a class called groovy.sql.Sql. Here we use this class to access our data from a database rather than hard-coding it into lists and maps. Closed Captioning: Unavailable Mobile-Friendly Format: Available on m.safaribooksonline.com Example Files: Not Applicable | 00:04:44 | |
Description: Explore the site where Major League Baseball keeps all their game data in XML form, which is updated nearly continuously. One of Groovy's best (and one of Java's most frustrating) features is its ability to work with XML. As a source of publicly available, relatively non-trivial XML data is provided by Major League Baseball in the form of game box scores. Here we introduce this data by examining the site where it is made available and look at some typical examples. Closed Captioning: Unavailable Mobile-Friendly Format: Available on m.safaribooksonline.com Example Files: Not Applicable | 00:05:20 | |
Description: Accessing XML data in Groovy is as easy as using a dot or ampersand operator and indexed values. Process the MLB boxscore to find all the quantities needed in its child elements and attributes. Now we use Groovy's easy GPath syntax to access XML data. We're able to dig through the XML results using simple path notation to find child elements and attributes in an almost trivial fashion. Most developers who normally use Java to work with XML data find this Groovy capability refreshing, and sometimes all by itself a good enough reason to use Groovy. Closed Captioning: Unavailable Mobile-Friendly Format: Available on m.safaribooksonline.com Example Files: Not Applicable | 00:08:42 | |
Maps and the "spread-dot" Operator Description: Groovy makes it particularly easy to process data in collections. Apply a datatype conversion to each value in a map and then sum them, all in one line. Another special Groovy operator is called the "spread-dot" operator, which allows us to apply methods to data in collections. Here we use that capability to convert all of our numerical information from strings into doubles for later processing. Closed Captioning: Unavailable Mobile-Friendly Format: Available on m.safaribooksonline.com Example Files: Not Applicable | 00:11:45 | |
Using Groovy builders to generate HTML Description: Missing the description. Describe the groovy concept being learned and then explain how how the example demonstrates the concept. Another of Groovy's capabilities that goes beyond Java is its ability to do metaprogramming. An example of this is how Groovy defines "builders", which are classes that intercept unknown method calls and use them to generate interesting output. In this section, we'll use Groovy's NodeBuilder class to write out HTML in an almost trivial fashion. Closed Captioning: Unavailable Mobile-Friendly Format: Available on m.safaribooksonline.com Example Files: Not Applicable | 00:12:16 | |
HTML "screen scraping" with Regular Expressions Description: Games on a given day can change, learn to access the web page for that day and parse it for a specific pattern. The regular expression used determines the home and away teams for each game and the path to the individual boxscores. Not all available HTML data can be processed by XML parsers, because it may not even be well formed. We observe that the web pages that link to the games for each day are in this category, and rather than try to fix them, we take them as an opportunity to process them as text using Groovy. This gives us a chance to show how to download an entire page in one line, then use sophisticated regular expressions to access and process the resulting information. Closed Captioning: Unavailable Mobile-Friendly Format: Available on m.safaribooksonline.com Example Files: Not Applicable | 00:11:32 | |
Accessing Games on a Given Day Description: A method is written to process the boxscores for every game on a given day, printing the game result, along with winning pitcher, losing pitcher, and saves, to the console. This section brings together the concepts of the previous few by writing a method that access the games for a given day and processes the resulting XML box scores, sending the results to the console. Closed Captioning: Unavailable Mobile-Friendly Format: Available on m.safaribooksonline.com Example Files: Not Applicable | 00:07:54 | |
Accessing Google's GeoLocator Service Description: Understand how to access the Google GeoLocator RESTful web service. Send address information to the service and parse the resulting string data. Here we use Groovy to access a RESTful web service and process the results. The service we need is a geolocator service provided by Google, which converts address information in latitude and longitude pairs. Groovy makes it easy to build the necessary query, and, as a new feature, we show how we can parse CSV responses into arrays and access them from the end rather than the beginning. Closed Captioning: Unavailable Mobile-Friendly Format: Available on m.safaribooksonline.com Example Files: Not Applicable | 00:08:53 | |
Description: The groovy.sql.Sql class is used to populate a database with latitudes and longitudes for each MLB stadium. Since the locations of stadiums don't change, we're better off saving the location data in a database rather than computing it each time. While previously we used the groovy.sql.Sql class to read data from a database, in this section we expand our use of this class to populate a database table with our location information. Closed Captioning: Unavailable Mobile-Friendly Format: Available on m.safaribooksonline.com Example Files: Not Applicable | 00:06:44 | |
Description: The GoogleMaps JavaScript API and can be used in a page without downloading anything explicitly. Instead we use the Google Ajax Loader service, which we also use to include the prototype JavaScript library. Here we convert our console based application into something more visual by introducing the Google Maps API. This section shows how to create a Google Map using Google's Ajax Loader service and the "prototype" JavaScript library. With this background, we can then proceed in the next couple of sections to use Groovy to supply the necessary map data in XML form. Closed Captioning: Unavailable Mobile-Friendly Format: Available on m.safaribooksonline.com Example Files: Not Applicable | 00:11:11 | |
Making Groovy Baseball a Web Service Description: Learn how to create a "RESTful" (or, more properly, a GETful) web service. Modify the script so that when the proper URL is invoked, the result is an XML response containing all the individual game results. Ajax applications need to see data in a format that JavaScript understands. Most server-side applications, however, generate data as objects in whatever programming language they are using. In order to bridge the gap, we need a common data format that both can understand. In this section, we use a Groovy builder to produce our game results in XML form, which can then be used by JavaScript in the web client. Closed Captioning: Unavailable Mobile-Friendly Format: Available on m.safaribooksonline.com Example Files: Not Applicable | 00:13:24 | |
Calling Our New Service using Ajax Description: The new web service is accessed using the prototype Ajax library. The returned XML is parsed, and each game is displayed as a marker on a GoogleMap whose location is the home stadium and whose info window contains the game result. Finally we bring all the pieces together, so that our web site makes Ajax calls to our server-side Groovy code to get the game data for a given day and then renders it on a Google Map. Closed Captioning: Unavailable Mobile-Friendly Format: Available on m.safaribooksonline.com Example Files: Not Applicable | 00:17:07 |
