| |
| |
Preface | |
| |
| |
| |
Introduction | |
| |
| |
| |
Groovy, the Way Java Should Be | |
| |
| |
| |
Stripping Away the Verbosity | |
| |
| |
| |
Groovy: The Blue Pill or the Red Pill? | |
| |
| |
| |
Road Map | |
| |
| |
| |
Acknowledgments | |
| |
| |
| |
Getting Started | |
| |
| |
| |
Installing Groovy | |
| |
| |
| |
Running a Groovy Script (groovy) | |
| |
| |
| |
Compiling Groovy (groovyc) | |
| |
| |
| |
Running the Groovy Shell (groovysh) | |
| |
| |
| |
Running the Groovy Console (groovyConsole) | |
| |
| |
| |
Running Groovy on a Web Server (Groovlets) | |
| |
| |
| |
Groovy + Eclipse | |
| |
| |
| |
Groovy + IntelliJ IDEA | |
| |
| |
| |
Groovy + TextMate | |
| |
| |
| |
Groovy + [Insert Your IDE or Text Editor Here] | |
| |
| |
| |
New to Groovy | |
| |
| |
| |
Automatic Imports | |
| |
| |
| |
Optional Semicolons | |
| |
| |
| |
Optional Parentheses | |
| |
| |
| |
Optional Return Statements | |
| |
| |
| |
Optional Datatype Declaration (Duck Typing) | |
| |
| |
| |
Optional Exception Handling | |
| |
| |
| |
Operator Overloading | |
| |
| |
| |
Safe Dereferencing (?) | |
| |
| |
| |
Autoboxing | |
| |
| |
| |
Groovy Truth | |
| |
| |
| |
Embedded Quotes | |
| |
| |
| |
Heredocs (Triple Quotes) | |
| |
| |
| |
GStrings | |
| |
| |
| |
List Shortcuts | |
| |
| |
| |
Map Shortcuts | |
| |
| |
| |
Ranges | |
| |
| |
| |
Closures and Blocks | |
| |
| |
| |
Java and Groovy Integration | |
| |
| |
| |
GroovyBeans (aka POGOs) | |
| |
| |
| |
Autogenerated Getters and Setters | |
| |
| |
| |
getProperty and SetProperty | |
| |
| |
| |
Making Attributes Read-Only | |
| |
| |
| |
Constructor Shortcut Syntax | |
| |
| |
| |
Optional Parameters/Default Values | |
| |
| |
| |
Private Methods | |
| |
| |
| |
Calling Groovy from Java | |
| |
| |
| |
Calling Java from Groovy | |
| |
| |
| |
Interfaces in Groovy and Java | |
| |
| |
| |
The Groovy Joint Compiler | |
| |
| |
| |
Compiling Your Project with Ant | |
| |
| |
| |
Compiling Your Project with Maven | |
| |
| |
| |
Groovy from the Command Line | |
| |
| |
| |
Running Uncompiled Groovy Scripts | |
| |
| |
| |
Shebanging Groovy | |
| |
| |
| |
Accepting Command-Line Arguments | |
| |
| |
| |
Running a Shell Command | |
| |
| |
| |
Using Shell Wildcards in Groovy Scripts | |
| |
| |
| |
Running Multiple Shell Commands at Once | |
| |
| |
| |
Waiting for a Shell Command to Finish Before Continuing | |
| |
| |
| |
Getting System Properties | |
| |
| |
| |
Getting Environment Variables | |
| |
| |
| |
Evaluating a String | |
| |
| |
| |
Calling Another Groovy Script | |
| |
| |
| |
Groovy on the Fly (groovy -e) | |
| |
| |
| |
Including JARs at the Command Line | |
| |
| |
| |
File Tricks | |
| |
| |
| |
Listing All Files in a Directory | |
| |
| |
| |
Reading the Contents of a File | |
| |
| |
| |
Writing Text to a File | |
| |
| |
| |
Copying Files | |
| |
| |
| |
Using AntBuilder to Copy a File | |
| |
| |
| |
Using AntBuilder to Copy a Directory | |
| |
| |
| |
Moving/Renaming Files | |
| |
| |
| |
Deleting Files | |
| |
| |
| |
Creating a ZIP File/Tarball | |
| |
| |
| |
Unzipping/Untarring Files | |
| |
| |
| |
Parsing XML | |
| |
| |
| |
The "I'm in a Hurry" Guide to Parsing XML | |
| |
| |
| |
Understanding the Difference Between XmlParser and XmlSlurper | |
| |
| |
| |
Parsing XML Documents | |
| |
| |
| |
Dealing with XML Attributes | |
| |
| |
| |
Getting the Body of an XML Element | |
| |
| |
| |
Dealing with Mixed-Case Element Names | |
| |
| |
| |
Dealing with Hyphenated Element Names | |
| |
| |
| |
Navigating Deeply Nested XML | |
| |
| |
| |
Parsing an XML Document with Namespaces | |
| |
| |
| |
Populating a GroovyBean from XML | |
| |
| |
| |
Writing XML | |
| |
| |
| |
The "I'm in a Hurry" Guide to Creating an XML Document | |
| |
| |
| |
Creating Mixed-Case Element Names | |
| |
| |
| |
Creating Hyphenated Element Names | |
| |
| |
| |
Creating Namespaced XML Using MarkupBuilder | |
| |
| |
| |
Understanding the Difference Between MarkupBuilder and StreamingMarkupBuilder | |
| |
| |
| |
Creating Parts of the XML Document Separately | |
| |
| |
| |
Creating Namespaced XML Using StreamingMarkupBuilder | |
| |
| |
| |
Printing Out the XML Declaration | |
| |
| |
| |
Printing Out Processing Instructions | |
| |
| |
| |
Printing Arbitrary Strings (Comments, CDATA) | |
| |
| |
| |
Writing StreamingMarkupBuilder Output to a File | |
| |
| |
| |
StreamingMarkupBuilder at a Glance | |
| |
| |
| |
Creating HTML on the Fly | |
| |
| |
| |
Converting CSV to XML | |
| |
| |
| |
Converting JDBC ResultSets to XML | |
| |
| |
| |
Web Services | |
| |
| |
| |
Finding Your Local IP Address and Name | |
| |
| |
| |
Finding a Remote IP Address and Domain Name | |
| |
| |
| |
Making an HTTP GET Request | |
| |
| |
| |
Working with Query Strings | |
| |
| |
| |
Making an HTTP POST Request | |
| |
| |
| |
Making an HTTP PUT Request | |
| |
| |
| |
Making an HTTP DELETE Request | |
| |
| |
| |
Making a RESTful Request | |
| |
| |
| |
Making a CSV Request | |
| |
| |
| |
Making a SOAP Request | |
| |
| |
| |
Making an XML-RPC Request | |
| |
| |
| |
Parsing Yahoo Search Results as XML | |
| |
| |
| |
Parsing an Atom Feed | |
| |
| |
| |
Parsing an RSS Feed | |
| |
| |
| |
Metaprogramming | |
| |
| |
| |
Discovering the Class | |
| |
| |
| |
Discovering the Fields of a Class | |
| |
| |
| |
Checking for the Existence of a Field | |
| |
| |
| |
Discovering the Methods of a Class | |
| |
| |
| |
Checking for the Existence of a Method | |
| |
| |
| |
Creating a Field Pointer | |
| |
| |
| |
Creating a Method Pointer | |
| |
| |
| |
Calling Methods That Don't Exist (invokeMethod) | |
| |
| |
| |
Creating an Expando | |
| |
| |
| |
Adding Methods to a Class Dynamically (Categories) | |
| |
| |
| |
Adding Methods to a Class Dynamically (ExpandoMetaClass) | |
| |
| |
| |
Working with Grails | |
| |
| |
| |
Installing Grails | |
| |
| |
| |
Creating Your First Grails App | |
| |
| |
| |
Understanding Grails Environments | |
| |
| |
| |
Running Grails on a Different Port | |
| |
| |
| |
Generating a WAR | |
| |
| |
| |
Changing Databases | |
| |
| |
| |
Changing the Home Page | |
| |
| |
| |
Understanding Controllers and Views | |
| |
| |
| |
Dynamic Scaffolding | |
| |
| |
| |
Validating Your Data | |
| |
| |
| |
Managing Table Relationships | |
| |
| |
| |
Mapping Classes to Legacy Databases | |
| |
| |
| |
Grails and Web Services | |
| |
| |
| |
Returning XML | |
| |
| |
| |
Returning JSON | |
| |
| |
| |
Returning an Excel Spreadsheet | |
| |
| |
| |
Setting Up an Atom Feed | |
| |
| |
| |
Setting Up an RSS Feed for Podcasts | |
| |
| |
| |
Installing Plug-Ins | |
| |
| |
Index | |