codecs
Purpose
Provides facility to register encoders and decoders of textual data as methods on any objectExamples
class HTMLCodec {
static encode = { theTarget ->
HtmlUtils.htmlEscape(theTarget.toString())
}
static decode = { theTarget ->
HtmlUtils.htmlUnescape(theTarget.toString())
}
}
assert "<p>Hello World!</p>" == "<p>Hello World!</p>".encodeAsHTML()
assert "<p>Hello World!</p>" == "<p>Hello World!</p>".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 Strings in the user guide.Provided Codecs:
HTMLCodec - encodes/decodes HTML mark-up
URLCodec - encodes/decodes URLs
JavascriptCodec - encodes (escapes) Javascript
Base64Codec - encodes/decodes Base64 data