Clover coverage report - Code Coverage for tapestry release 4.0-beta-12
Coverage timestamp: Sun Oct 30 2005 16:22:01 EST
file stats: LOC: 90   Methods: 4
NCLOC: 45   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ResponseRendererImpl.java 50% 100% 100% 95%
coverage coverage
 1    // Copyright 2004, 2005 The Apache Software Foundation
 2    //
 3    // Licensed under the Apache License, Version 2.0 (the "License");
 4    // you may not use this file except in compliance with the License.
 5    // You may obtain a copy of the License at
 6    //
 7    // http://www.apache.org/licenses/LICENSE-2.0
 8    //
 9    // Unless required by applicable law or agreed to in writing, software
 10    // distributed under the License is distributed on an "AS IS" BASIS,
 11    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12    // See the License for the specific language governing permissions and
 13    // limitations under the License.
 14   
 15    package org.apache.tapestry.services.impl;
 16   
 17    import java.io.IOException;
 18    import java.io.PrintWriter;
 19   
 20    import org.apache.tapestry.IMarkupWriter;
 21    import org.apache.tapestry.IPage;
 22    import org.apache.tapestry.IRequestCycle;
 23    import org.apache.tapestry.markup.MarkupWriterSource;
 24    import org.apache.tapestry.services.RequestLocaleManager;
 25    import org.apache.tapestry.services.ResponseRenderer;
 26    import org.apache.tapestry.util.ContentType;
 27    import org.apache.tapestry.web.WebResponse;
 28   
 29    /**
 30    * Responsible for rendering a response to the client.
 31    *
 32    * @author Howard M. Lewis Ship
 33    * @since 4.0
 34    */
 35    public class ResponseRendererImpl implements ResponseRenderer
 36    {
 37    private RequestLocaleManager _localeManager;
 38   
 39    private MarkupWriterSource _markupWriterSource;
 40   
 41    private WebResponse _webResponse;
 42   
 43    /**
 44    * Inside a {@link org.apache.tapestry.util.ContentType}, the output encoding is called
 45    * "charset".
 46    */
 47   
 48    public static final String ENCODING_KEY = "charset";
 49   
 50  130 public void renderResponse(IRequestCycle cycle) throws IOException
 51    {
 52  130 _localeManager.persistLocale();
 53   
 54  130 IPage page = cycle.getPage();
 55   
 56  130 ContentType contentType = page.getResponseContentType();
 57   
 58  130 String encoding = contentType.getParameter(ENCODING_KEY);
 59   
 60  130 if (encoding == null)
 61    {
 62  130 encoding = cycle.getEngine().getOutputEncoding();
 63   
 64  130 contentType.setParameter(ENCODING_KEY, encoding);
 65    }
 66   
 67  130 PrintWriter printWriter = _webResponse.getPrintWriter(contentType);
 68   
 69  130 IMarkupWriter writer = _markupWriterSource.newMarkupWriter(printWriter, contentType);
 70   
 71  130 cycle.renderPage(writer);
 72   
 73  122 writer.close();
 74    }
 75   
 76  39 public void setLocaleManager(RequestLocaleManager localeManager)
 77    {
 78  39 _localeManager = localeManager;
 79    }
 80   
 81  39 public void setMarkupWriterSource(MarkupWriterSource markupWriterSource)
 82    {
 83  39 _markupWriterSource = markupWriterSource;
 84    }
 85   
 86  39 public void setWebResponse(WebResponse webResponse)
 87    {
 88  39 _webResponse = webResponse;
 89    }
 90    }