Examples of StreamCharBuffer


Examples of org.grails.buffer.StreamCharBuffer

    public PrintWriter getWriter() throws IOException {
        if (usingStream) throw new IllegalStateException("Method getOutputStream() already called");

        if (!usingWriter) {
            usingWriter = true;
            charBuffer = new StreamCharBuffer();
            charBuffer.setNotifyParentBuffersEnabled(false);
            pw = GrailsPrintWriterAdapter.newInstance(charBuffer.getWriter());
        }
        return pw;
    }
View Full Code Here

Examples of org.grails.buffer.StreamCharBuffer

    @Test
    public void testPrintStreamCharBuffer() throws IOException {
        FastStringWriter stringwriter=new FastStringWriter();
        CodecPrintWriter writer=new CodecPrintWriter(stringwriter, getEncoder(new MockGrailsApplication(), HTMLCodec.class), registry);
        StreamCharBuffer buf=new StreamCharBuffer();
        buf.getWriter().write("&&");
        writer.write(buf);
        writer.flush();
        assertEquals("&&", stringwriter.getValue());
    }
View Full Code Here

Examples of org.grails.buffer.StreamCharBuffer

    @Test
    public void testPrintStreamCharBufferWithClosure() throws IOException {
        FastStringWriter stringwriter=new FastStringWriter();
        CodecPrintWriter writer=new CodecPrintWriter(stringwriter, getEncoder(new MockGrailsApplication(), CodecWithClosureProperties.class), registry);
        StreamCharBuffer buf=new StreamCharBuffer();
        buf.getWriter().write("hola");
        writer.write(buf);
        writer.flush();
        assertEquals("-> hola <-", stringwriter.getValue());
    }
View Full Code Here

Examples of org.grails.buffer.StreamCharBuffer

    }

    public InputStream parse() {
        resolveKeepGeneratedDirectory();

        StreamCharBuffer streamBuffer = new StreamCharBuffer(1024);
        StreamByteBuffer byteOutputBuffer = new StreamByteBuffer(1024,
                StreamByteBuffer.ReadMode.RETAIN_AFTER_READING);

        try {
            streamBuffer.connectTo(new OutputStreamWriter(byteOutputBuffer.getOutputStream(),
                    GROOVY_SOURCE_CHAR_ENCODING), true);
        }
        catch (UnsupportedEncodingException e) {
            throw new RuntimeException("Grails cannot run unless your environment supports UTF-8!");
        }

        File keepGeneratedFile = null;
        Writer keepGeneratedWriter = null;
        if (keepGeneratedDirectory != null) {
            keepGeneratedFile = new File(keepGeneratedDirectory, className);
            try {
                keepGeneratedWriter = new OutputStreamWriter(
                        new FileOutputStream(keepGeneratedFile),
                        GROOVY_SOURCE_CHAR_ENCODING);
            }
            catch (IOException e) {
                LOG.warn("Cannot open keepgenerated file for writing. File's absolute path is '" +
                        keepGeneratedFile.getAbsolutePath() + "'");
                keepGeneratedFile = null;
            }
            streamBuffer.connectTo(keepGeneratedWriter, true);
        }

        Writer target = streamBuffer.getWriter();
        try {
            generateGsp(target, false);

            if (LOG.isDebugEnabled()) {
                if (keepGeneratedFile != null) {
View Full Code Here

Examples of org.grails.buffer.StreamCharBuffer

        super(out);
        if (buffer) initBuffer();
    }

    void initBuffer() {
        streamBuffer = new StreamCharBuffer();
        streamBufferWriter = streamBuffer.getWriter();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.