Search in sources :

Example 1 with EncodedAppenderFactory

use of org.grails.encoder.EncodedAppenderFactory in project grails-core by grails.

the class GSPResponseWriter method getEncodedAppender.

public EncodedAppender getEncodedAppender() {
    if (buffer != null) {
        return ((EncodedAppenderFactory) buffer.getWriter()).getEncodedAppender();
    }
    activateDestination();
    Writer target = getTarget().unwrap();
    if (target != this && target instanceof EncodedAppenderFactory) {
        return ((EncodedAppenderFactory) target).getEncodedAppender();
    }
    return null;
}
Also used : EncodedAppenderFactory(org.grails.encoder.EncodedAppenderFactory) StreamCharBufferWriter(org.grails.buffer.StreamCharBuffer.StreamCharBufferWriter) LazyInitializingWriter(org.grails.buffer.StreamCharBuffer.LazyInitializingWriter) GrailsRoutablePrintWriter(org.grails.web.sitemesh.GrailsRoutablePrintWriter) Writer(java.io.Writer)

Example 2 with EncodedAppenderFactory

use of org.grails.encoder.EncodedAppenderFactory in project grails-core by grails.

the class CodecPrintWriter method getEncodedAppender.

public EncodedAppender getEncodedAppender() {
    EncodedAppender encodedAppender = ((EncodedAppenderFactory) buffer.getWriter()).getEncodedAppender();
    encodedAppender.setIgnoreEncodingState(ignoreEncodingState);
    return encodedAppender;
}
Also used : EncodedAppender(org.grails.encoder.EncodedAppender) EncodedAppenderFactory(org.grails.encoder.EncodedAppenderFactory)

Example 3 with EncodedAppenderFactory

use of org.grails.encoder.EncodedAppenderFactory in project grails-core by grails.

the class StreamCharBuffer method writeToEncodedAppender.

private static boolean writeToEncodedAppender(StreamCharBuffer source, Writer target, EncodedAppender notAllowedAppender, boolean flush) throws IOException {
    if (target instanceof EncodedAppenderFactory) {
        EncodedAppenderFactory eaw = (EncodedAppenderFactory) target;
        EncodedAppender appender = eaw.getEncodedAppender();
        if (appender != null) {
            if (appender == notAllowedAppender) {
                throw new IllegalArgumentException("Cannot write buffer to itself.");
            }
            Encoder encoder = null;
            if (target instanceof EncoderAware) {
                encoder = ((EncoderAware) target).getEncoder();
            }
            if (encoder == null && appender instanceof EncoderAware) {
                encoder = ((EncoderAware) appender).getEncoder();
            }
            source.encodeTo(appender, encoder);
            if (flush) {
                appender.flush();
            }
            return true;
        }
    }
    return false;
}
Also used : WriterEncodedAppender(org.grails.encoder.WriterEncodedAppender) AbstractEncodedAppender(org.grails.encoder.AbstractEncodedAppender) EncodedAppender(org.grails.encoder.EncodedAppender) Encoder(org.grails.encoder.Encoder) StreamingEncoder(org.grails.encoder.StreamingEncoder) EncodedAppenderFactory(org.grails.encoder.EncodedAppenderFactory) EncoderAware(org.grails.encoder.EncoderAware)

Aggregations

EncodedAppenderFactory (org.grails.encoder.EncodedAppenderFactory)3 EncodedAppender (org.grails.encoder.EncodedAppender)2 Writer (java.io.Writer)1 LazyInitializingWriter (org.grails.buffer.StreamCharBuffer.LazyInitializingWriter)1 StreamCharBufferWriter (org.grails.buffer.StreamCharBuffer.StreamCharBufferWriter)1 AbstractEncodedAppender (org.grails.encoder.AbstractEncodedAppender)1 Encoder (org.grails.encoder.Encoder)1 EncoderAware (org.grails.encoder.EncoderAware)1 StreamingEncoder (org.grails.encoder.StreamingEncoder)1 WriterEncodedAppender (org.grails.encoder.WriterEncodedAppender)1 GrailsRoutablePrintWriter (org.grails.web.sitemesh.GrailsRoutablePrintWriter)1