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