Clover coverage report - Code Coverage for tapestry release 4.0-beta-2
Coverage timestamp: Sat Jul 9 2005 22:02:17 EDT
file stats: LOC: 77   Methods: 5
NCLOC: 42   Classes: 1
30 day Evaluation License registered to hlship@comcast.net Your 30 day evaluation period has expired. Please visit http://www.cenqua.com to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
CookieSourceImpl.java 100% 100% 100% 100%
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 javax.servlet.http.Cookie;
 18    import javax.servlet.http.HttpServletRequest;
 19    import javax.servlet.http.HttpServletResponse;
 20   
 21    import org.apache.tapestry.services.CookieSource;
 22   
 23    /**
 24    * Implementation of the {@link org.apache.tapestry.services.CookieSource}service interface.
 25    *
 26    * @author Howard Lewis Ship
 27    * @since 4.0
 28    */
 29    public class CookieSourceImpl implements CookieSource
 30    {
 31    private HttpServletRequest _request;
 32   
 33    private HttpServletResponse _response;
 34   
 35  135 public String readCookieValue(String name)
 36    {
 37  135 Cookie[] cookies = _request.getCookies();
 38   
 39  135 if (cookies == null)
 40  1 return null;
 41   
 42  134 for (int i = 0; i < cookies.length; i++)
 43    {
 44  12 if (cookies[i].getName().equals(name))
 45  10 return cookies[i].getValue();
 46    }
 47   
 48  124 return null;
 49    }
 50   
 51  13 public void writeCookieValue(String name, String value)
 52    {
 53  13 Cookie cookie = new Cookie(name, value);
 54  13 cookie.setPath(_request.getContextPath());
 55   
 56  13 _response.addCookie(cookie);
 57    }
 58   
 59  1 public void removeCookieValue(String name)
 60    {
 61  1 Cookie cookie = new Cookie(name, null);
 62  1 cookie.setPath(_request.getContextPath());
 63  1 cookie.setMaxAge(0);
 64   
 65  1 _response.addCookie(cookie);
 66    }
 67   
 68  46 public void setRequest(HttpServletRequest request)
 69    {
 70  46 _request = request;
 71    }
 72   
 73  43 public void setResponse(HttpServletResponse response)
 74    {
 75  43 _response = response;
 76    }
 77    }