Search in sources :

Example 1 with EncoderAware

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

AbstractEncodedAppender (org.grails.encoder.AbstractEncodedAppender)1 EncodedAppender (org.grails.encoder.EncodedAppender)1 EncodedAppenderFactory (org.grails.encoder.EncodedAppenderFactory)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