Search in sources :

Example 1 with EncodingStateRegistry

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

the class StreamCharBuffer method createEncodingInitializer.

public LazyInitializingWriter createEncodingInitializer(final EncoderAware encoderLookup, final EncodingStateRegistryLookup encodingStateRegistryLookup, final LazyInitializingWriter... writers) {
    LazyInitializingWriter encodingWriterInitializer = new LazyInitializingMultipleWriter() {

        Writer lazyWriter;

        public Writer getWriter() throws IOException {
            return lazyWriter;
        }

        public LazyInitializingWriter[] initializeMultiple(StreamCharBuffer buffer, boolean autoFlushMode) throws IOException {
            Encoder encoder = encoderLookup.getEncoder();
            if (encoder != null) {
                EncodingStateRegistry encodingStateRegistry = encodingStateRegistryLookup.lookup();
                StreamCharBuffer encodeBuffer = new StreamCharBuffer(chunkSize, growProcent, maxChunkSize);
                encodeBuffer.setAllowSubBuffers(false);
                lazyWriter = encodeBuffer.getWriterForEncoder(encoder, encodingStateRegistry);
                for (LazyInitializingWriter w : writers) {
                    encodeBuffer.connectTo(w, autoFlushMode);
                }
                return new LazyInitializingWriter[] { this };
            } else {
                return writers;
            }
        }
    };
    return encodingWriterInitializer;
}
Also used : EncodingStateRegistry(org.grails.encoder.EncodingStateRegistry) Encoder(org.grails.encoder.Encoder) StreamingEncoder(org.grails.encoder.StreamingEncoder) Writer(java.io.Writer) EncodedAppenderWriter(org.grails.encoder.EncodedAppenderWriter) OutputStreamWriter(java.io.OutputStreamWriter) EncodesToWriter(org.grails.encoder.EncodesToWriter)

Aggregations

OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 EncodedAppenderWriter (org.grails.encoder.EncodedAppenderWriter)1 Encoder (org.grails.encoder.Encoder)1 EncodesToWriter (org.grails.encoder.EncodesToWriter)1 EncodingStateRegistry (org.grails.encoder.EncodingStateRegistry)1 StreamingEncoder (org.grails.encoder.StreamingEncoder)1