Search in sources :

Example 1 with StreamingEncoderWritable

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

the class JSONObject method writeQuoted.

static void writeQuoted(Writer writer, Object value) throws IOException {
    if (useStreamingJavascriptEncoder) {
        writer.write("\"");
        if (value.getClass() == String.class || value.getClass() == StringBuilder.class || value.getClass() == StringBuffer.class) {
            encodeToWriter((CharSequence) value, writer);
        } else if (value instanceof StreamingEncoderWritable) {
            ((StreamingEncoderWritable) value).encodeTo(writer, javascriptEncoderStateless);
        } else if (value instanceof Writable) {
            ((Writable) value).writeTo(new StreamingEncoderWriter(writer, javascriptEncoder, null));
        } else {
            encodeToWriter(value.toString(), writer);
        }
        writer.write("\"");
    } else {
        writer.write(valueToString(value));
    }
}
Also used : StreamingEncoderWriter(org.grails.encoder.StreamingEncoderWriter) StreamingEncoderWritable(org.grails.encoder.StreamingEncoderWritable) Writable(groovy.lang.Writable) StreamingEncoderWritable(org.grails.encoder.StreamingEncoderWritable)

Aggregations

Writable (groovy.lang.Writable)1 StreamingEncoderWritable (org.grails.encoder.StreamingEncoderWritable)1 StreamingEncoderWriter (org.grails.encoder.StreamingEncoderWriter)1