Clover coverage report - Code Coverage for tapestry release 4.0-alpha-3
Coverage timestamp: Mon May 16 2005 09:05:49 EDT
file stats: LOC: 90   Methods: 4
NCLOC: 45   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 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  158
     public void renderResponse(IRequestCycle cycle) throws IOException
 51   
     {
 52  158
         _localeManager.persistLocale();
 53   
 
 54  158
         IPage page = cycle.getPage();
 55   
 
 56  158
         ContentType contentType = page.getResponseContentType();
 57   
 
 58  158
         String encoding = contentType.getParameter(ENCODING_KEY);
 59   
 
 60  158
         if (encoding == null)
 61   
         {
 62  158
             encoding = cycle.getEngine().getOutputEncoding();
 63   
 
 64  158
             contentType.setParameter(ENCODING_KEY, encoding);
 65   
         }
 66   
 
 67  158
         PrintWriter printWriter = _webResponse.getPrintWriter(contentType);
 68   
 
 69  158
         IMarkupWriter writer = _markupWriterSource.newMarkupWriter(printWriter, contentType);
 70   
 
 71  158
         cycle.renderPage(writer);
 72   
 
 73  147
         writer.close();
 74   
     }
 75   
 
 76  45
     public void setLocaleManager(RequestLocaleManager localeManager)
 77   
     {
 78  45
         _localeManager = localeManager;
 79   
     }
 80   
 
 81  45
     public void setMarkupWriterSource(MarkupWriterSource markupWriterSource)
 82   
     {
 83  45
         _markupWriterSource = markupWriterSource;
 84   
     }
 85   
 
 86  45
     public void setWebResponse(WebResponse webResponse)
 87   
     {
 88  45
         _webResponse = webResponse;
 89   
     }
 90   
 }