"Fossies" - the Fresh Open Source Software Archive

Member "grails-core-5.2.4/grails-docs/src/test/resources/docs/ref/Plug-ins/codecs.html" (14 Sep 2022, 61550 Bytes) of package /linux/www/grails-core-5.2.4.tar.gz:


Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the grails-core-5.2.4.tar.gz project site itself.

(Quick Reference)

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 "&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 plugin searches for classes with names that end in the convention Codec and dynamically registers encodeAs[Codec] and decode[Codec] 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-up

  • URLCodec - encodes/decodes URLs

  • JavascriptCodec - encodes (escapes) JavaScript

  • Base64Codec - encodes/decodes Base64 data

  • HexCodec - encodes a byte array or list of integers into a hex string, and decodes hex strings into byte array

  • MD5Codec - 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 string

  • MD5BytesCodec - 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 array

  • SHA1Codec - 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 string

  • SHA1BytesCodec - 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 array

  • SHA256Codec - 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 string

  • SHA256BytesCodec - 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