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;
}
Aggregations