codecs

Purpose

Provides facility to register encoders and decoders of textual data as methods on any object

Examples


class HTMLCodec {
    static encode = { theTarget ->
        HtmlUtils.htmlEscape(theTarget.toString())
    }    
    static decode = { theTarget ->
    	HtmlUtils.htmlUnescape(theTarget.toString())
    }
}
assert "&lt;p&gt;Hello World!&lt;/p&gt;" == "<p>Hello World!</p>".encodeAsHTML()
assert "<p>Hello World!</p>" == "&lt;p&gt;Hello World!&lt;/p&gt;".decodeHTML()

Description

This plug-in searches for classes that end in the convention Codec and dynamically registers encodeAsCodec and decodeCodec methods on java.lang.Object so that any data can be encoded and decoded. For more information refer to the section of Encoding and Decoding Objects in the user guide.

Provided Codecs: