Search in sources :

Example 11 with FastStringWriter

use of org.grails.buffer.FastStringWriter in project grails-core by grails.

the class DefaultUrlCreator method createURLWithWebRequest.

@SuppressWarnings("unchecked")
private String createURLWithWebRequest(Map parameterValues, GrailsWebRequest webRequest, boolean includeContextPath) {
    GrailsRequestStateLookupStrategy requestStateLookupStrategy = new DefaultRequestStateLookupStrategy(webRequest);
    final String encoding = requestStateLookupStrategy.getCharacterEncoding();
    String id = null;
    if (parameterValues.containsKey(ARGUMENT_ID)) {
        Object o = parameterValues.get(ARGUMENT_ID);
        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();
}
Also used : GrailsRequestStateLookupStrategy(org.grails.web.servlet.mvc.GrailsRequestStateLookupStrategy) DefaultRequestStateLookupStrategy(org.grails.web.servlet.mvc.DefaultRequestStateLookupStrategy) FastStringWriter(org.grails.buffer.FastStringWriter)

Example 12 with FastStringWriter

use of org.grails.buffer.FastStringWriter in project grails-core by grails.

the class XML method toString.

@Override
public String toString() {
    FastStringWriter strw = new FastStringWriter();
    render(strw);
    strw.flush();
    return strw.toString();
}
Also used : FastStringWriter(org.grails.buffer.FastStringWriter)

Aggregations

FastStringWriter (org.grails.buffer.FastStringWriter)12 CodecPrintWriter (org.grails.buffer.CodecPrintWriter)5 Test (org.junit.Test)5 StreamCharBuffer (org.grails.buffer.StreamCharBuffer)2 HTMLCodec (org.grails.plugins.codecs.HTMLCodec)2 ConfigMap (grails.config.ConfigMap)1 GrailsDomainClass (grails.core.GrailsDomainClass)1 Template (groovy.text.Template)1 Matcher (java.util.regex.Matcher)1 GrailsPrintWriter (org.grails.buffer.GrailsPrintWriter)1 GroovySyntaxTag (org.grails.gsp.compiler.tags.GroovySyntaxTag)1 GrailsTagException (org.grails.taglib.GrailsTagException)1 OutputEncodingStack (org.grails.taglib.encoder.OutputEncodingStack)1 DefaultRequestStateLookupStrategy (org.grails.web.servlet.mvc.DefaultRequestStateLookupStrategy)1 GrailsRequestStateLookupStrategy (org.grails.web.servlet.mvc.GrailsRequestStateLookupStrategy)1 GrailsWebRequest (org.grails.web.servlet.mvc.GrailsWebRequest)1 ByteArrayResource (org.springframework.core.io.ByteArrayResource)1