Search in sources :

Example 1 with EncodedAppender

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

the class StreamCharBuffer method getWriterForEncoder.

public Writer getWriterForEncoder(Encoder encoder, EncodingStateRegistry encodingStateRegistry, boolean ignoreEncodingState) {
    EncodedAppender encodedAppender = writer.getEncodedAppender();
    encodedAppender.setIgnoreEncodingState(ignoreEncodingState);
    return new EncodedAppenderWriter(encodedAppender, encoder, encodingStateRegistry);
}
Also used : WriterEncodedAppender(org.grails.encoder.WriterEncodedAppender) AbstractEncodedAppender(org.grails.encoder.AbstractEncodedAppender) EncodedAppender(org.grails.encoder.EncodedAppender) EncodedAppenderWriter(org.grails.encoder.EncodedAppenderWriter)

Example 2 with EncodedAppender

use of org.grails.encoder.EncodedAppender 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 EncodedAppender

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

the class StreamCharBuffer method encodeToBuffer.

public StreamCharBuffer encodeToBuffer(Encoder encoder, boolean allowSubBuffers, boolean notifyParentBuffersEnabled) {
    StreamCharBuffer coded = new StreamCharBuffer(Math.min(Math.max(totalChunkSize, chunkSize) * 12 / 10, maxChunkSize));
    coded.setAllowSubBuffers(allowSubBuffers);
    coded.setNotifyParentBuffersEnabled(notifyParentBuffersEnabled);
    EncodedAppender codedWriter = coded.writer.getEncodedAppender();
    try {
        encodeTo(codedWriter, encoder);
    } catch (IOException e) {
        // Should not ever happen
        log.error("IOException in StreamCharBuffer.encodeToBuffer", e);
    }
    return coded;
}
Also used : WriterEncodedAppender(org.grails.encoder.WriterEncodedAppender) AbstractEncodedAppender(org.grails.encoder.AbstractEncodedAppender) EncodedAppender(org.grails.encoder.EncodedAppender) IOException(java.io.IOException)

Example 4 with EncodedAppender

use of org.grails.encoder.EncodedAppender 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

EncodedAppender (org.grails.encoder.EncodedAppender)4 AbstractEncodedAppender (org.grails.encoder.AbstractEncodedAppender)3 WriterEncodedAppender (org.grails.encoder.WriterEncodedAppender)3 EncodedAppenderFactory (org.grails.encoder.EncodedAppenderFactory)2 IOException (java.io.IOException)1 EncodedAppenderWriter (org.grails.encoder.EncodedAppenderWriter)1 Encoder (org.grails.encoder.Encoder)1 EncoderAware (org.grails.encoder.EncoderAware)1 StreamingEncoder (org.grails.encoder.StreamingEncoder)1