Xml2Groovy (Griffon 0.9.5-rc2)
Date: 2012-03-09

Overview | Package | Class | Deprecated | Index | Help
| Griffon 0.9.5-rc2
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## griffon.util
[Java] Class Xml2Groovy

    java.lang.Object
      griffon.util.Xml2Groovy

    public final class Xml2Groovy
    extends Object

Translates an XML file into a Groovy script that is suitable for a Groovy builder. String literals must be escaped either using single or double quotes.

This helper class is useful for translating an XML View definition into a Groovy script that can be handled by an UberBuilder, for example this View

    <application title="app.config.application.title"
                 pack="true">
        <actions>
            <action id="'clickAction'"
                    name="'Click'"
                    closure="{controller.click(it)}"/>
        </actions>

        <gridLayout cols="1" rows="3"/>
        <textField id="'input'" columns="20"
            text="bind('value', target: model)"/>
        <textField id="'output'" columns="20"
            text="bind{model.value}" editable="false"/>
        <button action="clickAction"/>
    </application>

results in the following script

    application(title: app.config.application.title, pack: true) {
      actions {
        action(id: 'clickAction', name: 'Click', closure: {controller.click(it)})
      }
      gridLayout(cols: 1, rows: 3)
      textField(id: 'input', text: bind('value', target: model), columns: 20)
      textField(id: 'output', text: bind{model.value}, columns: 20, editable: false)
      button(action: clickAction)
    }

Authors:
  Andres Almiray

Field Summary
`private static Xml2Groovy` | `INSTANCE`

Constructor Summary
`private Xml2Groovy()`

Method Summary
`private IndentPrinter` | `createIndentPrinter(OutputStream os)`
`static Xml2Groovy` | `getInstance()`
`private XmlSlurper` | `newXmlSlurper()`
`String` | `parse(File file)`
`String` | `parse(InputSource source)`
`String` | `parse(InputStream stream)`
`String` | `parse(Reader reader)`
`String` | `parse(String uri)`
`String` | `parse(GPathResult root)`
`String` | `parseText(String text)`
`private String` | `translate(GPathResult root)`
`private void` | `walkXml(IndentPrinter printer, NodeChild node)`
`private void` | `walkXml(IndentPrinter printer, Node node)`

Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll

Field Detail

### INSTANCE

    private static final Xml2Groovy INSTANCE

Constructor Detail

### Xml2Groovy

    private Xml2Groovy()

Method Detail

### createIndentPrinter

    private IndentPrinter createIndentPrinter(OutputStream os)

### getInstance

    public static Xml2Groovy getInstance()

### newXmlSlurper

    private XmlSlurper newXmlSlurper()

### parse

    public String parse(File file)

### parse

    public String parse(InputSource source)

### parse

    public String parse(InputStream stream)

### parse

    public String parse(Reader reader)

### parse

    public String parse(String uri)

### parse

    public String parse(GPathResult root)

### parseText

    public String parseText(String text)

### translate

    private String translate(GPathResult root)

### walkXml

    private void walkXml(IndentPrinter printer, NodeChild node)

### walkXml

    private void walkXml(IndentPrinter printer, Node node)

Groovy Documentation