Package org.grails.buffer

Examples of org.grails.buffer.FastStringWriter


            if (o != null) {
                id = o.toString();
            }
        }

        FastStringWriter actualUriBuf = new FastStringWriter();
        if (includeContextPath) {
            actualUriBuf.append(requestStateLookupStrategy.getContextPath());
        }
        if (actionName != null) {
            if (actionName.indexOf(SLASH) > -1) {
                actualUriBuf.append(actionName);
            }
            else {
                if (controllerName != null) {
                    appendUrlToken(actualUriBuf, controllerName, encoding);
                }
                else {
                    appendUrlToken(actualUriBuf, requestStateLookupStrategy.getControllerName(), encoding);
                }
            }
            appendUrlToken(actualUriBuf, actionName, encoding);
        }
        if (id != null) {
            appendUrlToken(actualUriBuf, id, encoding);
        }
        appendRequestParams(actualUriBuf, parameterValues, encoding);
        return actualUriBuf.toString();
    }
View Full Code Here


    public String getTemplateURI(String controllerName, String templateName) {
        if (templateName.startsWith(SLASH_STR)) {
            return getAbsoluteTemplateURI(templateName);
        }

        FastStringWriter buf = new FastStringWriter();
        String pathToTemplate = BLANK;

        int lastSlash = templateName.lastIndexOf(SLASH);
        if (lastSlash > -1) {
            pathToTemplate = templateName.substring(0, lastSlash + 1);
            templateName = templateName.substring(lastSlash + 1);
        }
        if(controllerName != null) {
            buf.append(SLASH)
               .append(controllerName);
        }
        buf.append(SLASH)
           .append(pathToTemplate)
           .append(UNDERSCORE)
           .append(templateName);
        return buf.append(EXTENSION).toString();
    }
View Full Code Here

     *
     * @param templateName The template name normally beginning with /
     * @return The template URI
     */
    public String getAbsoluteTemplateURI(String templateName) {
        FastStringWriter buf = new FastStringWriter();
        String tmp = templateName.substring(1,templateName.length());
        if (tmp.indexOf(SLASH) > -1) {
            buf.append(SLASH);
            int i = tmp.lastIndexOf(SLASH);
            buf.append(tmp.substring(0, i));
            buf.append(SLASH_UNDR);
            buf.append(tmp.substring(i + 1,tmp.length()));
        }
        else {
            buf.append(SLASH_UNDR);
            buf.append(templateName.substring(1,templateName.length()));
        }
        String uri = buf.append(EXTENSION).toString();
        buf.close();
        return uri;
    }
View Full Code Here

     * @param controllerName The name of the controller
     * @param viewName The name of the view
     * @return The view URI
     */
    public String getViewURI(String controllerName, String viewName) {
        FastStringWriter buf = new FastStringWriter();

        return getViewURIInternal(controllerName, viewName, buf, true);
    }
View Full Code Here

     *
     * @param viewName The name of the view
     * @return The view URI
     */
    public String getAbsoluteViewURI(String viewName) {
        FastStringWriter buf = new FastStringWriter();
        return getAbsoluteViewURIInternal(viewName, buf, true);
    }
View Full Code Here

     * @param controllerName The name of the controller
     * @param viewName The name of the view
     * @return The view URI
     */
    public String getNoSuffixViewURI(String controllerName, String viewName) {
        FastStringWriter buf = new FastStringWriter();

        return getViewURIInternal(controllerName, viewName, buf, false);
    }
View Full Code Here

     * @param controllerName The name of the controller
     * @param viewName The name of the view
     * @return The view URI
     */
    public String getDeployedViewURI(String controllerName, String viewName) {
        FastStringWriter buf = new FastStringWriter(PATH_TO_VIEWS);
        return getViewURIInternal(controllerName, viewName, buf, true);
    }
View Full Code Here

     * Obtains a view URI when deployed within the /WEB-INF/grails-app/views context
     * @param viewName The name of the view
     * @return The view URI
     */
    public String getDeployedAbsoluteViewURI(String viewName) {
        FastStringWriter buf = new FastStringWriter(PATH_TO_VIEWS);
        return getAbsoluteViewURIInternal(viewName, buf, true);
    }
View Full Code Here

        new Builder(this).execute(c);
    }

    @Override
    public String toString() {
        FastStringWriter strw = new FastStringWriter();
        render(strw);
        strw.flush();
        return strw.toString();
    }
View Full Code Here

        assertEquals("-> hola <-", stringwriter.getValue());
    }

    @Test
    public void testCodecAndNoCodecGRAILS8405() throws IOException {
        FastStringWriter target = new FastStringWriter();

        GrailsWebRequest webRequest = bindMockHttpRequest();

        // Initialize out and codecOut as it is done in GroovyPage.initRun
        OutputEncodingStack outputStack = OutputEncodingStack.currentStack(true, target, false, true);
        GrailsPrintWriter out = outputStack.getOutWriter();
        webRequest.setOut(out);
        GrailsPrintWriter codecOut = new CodecPrintWriter(out, getEncoder(new MockGrailsApplication(), CodecWithClosureProperties.class), registry);

        // print some output
        codecOut.print("hola");
        codecOut.flush();
        out.print("1");
        out.print("2");
        out.print("3");

        // similar as taglib call
        FastStringWriter bufferWriter=new FastStringWriter();
        GrailsPrintWriter out2=new GrailsPrintWriter(bufferWriter);
        outputStack.push(out2);
        out.print("4");
        codecOut.print("A");
        codecOut.flush();
        outputStack.pop();

        // add output before appending "taglib output"
        out.print("added");
        codecOut.print("too");
        codecOut.flush();

        // append "taglib output"
        out.leftShift(bufferWriter.getBuffer());

        // print some more output
        codecOut.print("B");
        codecOut.flush();
        out.print("5");
View Full Code Here

TOP

Related Classes of org.grails.buffer.FastStringWriter

Copyright © 2018 www.massapicom. 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.