O'Reilly logo

Programming Groovy 2 by Venkat Subramaniam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using BuilderSupport

We saw how to create a custom builder using methodMissing and propertyMissing. If we’re creating more than one builder, chances are we’ll refactor some of the method-recognition code into a common base class. That has been done for us; the class BuilderSupport provides convenience methods that recognize the node structure. Instead of writing the logic to deal with the structure, we simply listen to calls as Groovy traverses the structure and takes appropriate action. Extending the abstract class BuilderSupport feels like working with Simple API for XML (SAX)—a popular event-driven parser for XML. It triggers events on a handler we provide as it parses and recognizes elements and attributes in a document.

Let’s look at ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required