use of org.grails.encoder.EncodedAppenderWriterFactory in project grails-core by grails.
the class GroovyPagesTemplateRenderer method wrapWriterWithEncoder.
private Writer wrapWriterWithEncoder(GrailsWebRequest webRequest, Map<String, Object> attrs, Writer out) {
Object encodeAs = attrs.get(GroovyPage.ENCODE_AS_ATTRIBUTE_NAME);
if (encodeAs != null) {
Map<String, Object> codecSettings = WithCodecHelper.makeSettingsCanonical(encodeAs);
String codecForTaglibs = (String) codecSettings.get(OutputEncodingSettings.TAGLIB_CODEC_NAME);
if (codecForTaglibs != null) {
Encoder encoder = WithCodecHelper.lookupEncoder(webRequest.getAttributes().getGrailsApplication(), codecForTaglibs);
if (out instanceof EncodedAppenderWriterFactory) {
out = ((EncodedAppenderWriterFactory) out).getWriterForEncoder(encoder, webRequest.getEncodingStateRegistry());
} else if (encoder instanceof StreamingEncoder) {
out = new StreamingEncoderWriter(out, (StreamingEncoder) encoder, webRequest.getEncodingStateRegistry());
} else {
out = new CodecPrintWriter(out, encoder, webRequest.getEncodingStateRegistry());
}
}
}
return out;
}
Aggregations