Package: org.grails.taglib.encoder

## [Groovy] Class WithCodecHelper

- org.grails.taglib.encoder.WithCodecHelper

- Helper methods for withCodec feature.

  Authors:
    Lari Hotari
  Since:
    2.3

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static java.lang.String` | `ALL_CODECS_FALLBACK_KEY_NAME` | all is the key to set all codecs at once
    `static java.lang.String` | `OUT_AND_EXPRESSION_CODECS_FALLBACK_KEY_NAME` | name is the key to set out and expression codecs at once

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `static Builder` | `createOutputStackAttributesBuilder(java.lang.Object codecInfo, GrailsApplication grailsApplication)` Creates a builder for building a new OutputEncodingStackAttributes instance
    `` | `static Encoder` | `lookupEncoder(GrailsApplication grailsApplication, java.lang.String codecName)`
    `` | `static java.util.Map<java.lang.String, java.lang.Object>` | `makeSettingsCanonical(java.lang.Object codecInfo)`
    `` | `static java.util.Map<java.lang.String, java.lang.Object>` | `mergeSettingsAndMakeCanonical(java.lang.Object currentSettings, java.util.Map<java.lang.String, java.lang.Object> parentSettings)`
    `<T>` | `static T` | `withCodec(GrailsApplication grailsApplication, java.lang.Object codecInfo, groovy.lang.Closure<T> closure)` Executes closure with given codecs.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Field Detail

    - #### public static final java.lang.String ALL_CODECS_FALLBACK_KEY_NAME

      all is the key to set all codecs at once

    - #### public static final java.lang.String OUT_AND_EXPRESSION_CODECS_FALLBACK_KEY_NAME

      name is the key to set out and expression codecs at once

  - ### Method Detail

    - #### static Builder createOutputStackAttributesBuilder(java.lang.Object codecInfo, GrailsApplication grailsApplication)

      Creates a builder for building a new OutputEncodingStackAttributes instance

      Parameters:
        `codecInfo` - the codec info, see withCodec method for more info
        `grailsApplication` - the grails application
      Returns:
        the builder instance for building OutputEncodingStackAttributes instance

    - #### static Encoder lookupEncoder(GrailsApplication grailsApplication, java.lang.String codecName)

    - #### static java.util.Map<java.lang.String, java.lang.Object> makeSettingsCanonical(java.lang.Object codecInfo)

    - #### static java.util.Map<java.lang.String, java.lang.Object> mergeSettingsAndMakeCanonical(java.lang.Object currentSettings, java.util.Map<java.lang.String, java.lang.Object> parentSettings)

    - #### <T> static T withCodec(GrailsApplication grailsApplication, java.lang.Object codecInfo, groovy.lang.Closure<T> closure)

      Executes closure with given codecs. codecInfo parameter can be a single String value or a java.util.Map. When it's a single String value, "out", "expression" and "taglib" get set with the given codec When it's a java.util.Map, these keys get used:

      - scriptlet - escapes output from scriptlets to output (the codec attached to "out" writer instance in GSP scriptlets)
      - taglib - escapes output from taglibs to output (the codec attached to "out" writer instance in taglibs)
      - expression - escapes values inside ${} to output
      - static - escapes the static html parts coming from the GSP file to output
      These keys set several codecs at once:
      - all - sets scriptlet, taglib, expression and static
      - name - sets scriptlet, taglib and expression
      In addition there is
      - inherit (boolean) - defaults to true. Controls whether codecs should be inherited to deeper level (taglib calls)
      - replaceonly (boolean) - defaults to false. Codecs will be only replaced if the previous inherited codec is safe.
      Parameters:
        `grailsApplication` - the grailsApplication instance
        `codecInfo` - this parameter is explained above
        `closure` - the closure to execute
      Returns:
        the return value of the closure