codecs
Purpose
Provides the 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 "<p>Hello World!</p>" == "<p>Hello World!</p>".encodeAsHTML() assert "<p>Hello World!</p>" == "<p>Hello World!</p>".decodeHTML()
Description
This plugin searches for classes with names 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:
HTMLCodec
- encodes/decodes HTML mark-upURLCodec
- encodes/decodes URLsJavascriptCodec
- encodes (escapes) JavaScriptBase64Codec
- encodes/decodes Base64 dataHexCodec
- encodes a byte array or list of integers into a hex string, and decodes hex strings into byte arrayMD5Codec
- encodes a byte array or list of integers, or the characters of a string (using default system encoding) into an MD5 digest as a hex stringMD5BytesCodec
- encodes a byte array or list of integers, or the characters of a string (using default system encoding) into an MD5 digest as a byte arraySHA1Codec
- encodes a byte array or list of integers, or the characters of a string (using default system encoding) into an SHA1 digest as a hex stringSHA1BytesCodec
- encodes a byte array or list of integers, or the characters of a string (using default system encoding) into an SHA1 digest as a byte arraySHA256Codec
- encodes a byte array or list of integers, or the characters of a string (using default system encoding) into an SHA256 digest as a hex stringSHA256BytesCodec
- encodes byte array or list of integers, or the characters of a string (using default system encoding) into an SHA256 digest as a byte array