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: 93   Methods: 7
NCLOC: 37   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
AbsoluteLinkRenderer.java - 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.link;
 16   
 17    import org.apache.tapestry.IRequestCycle;
 18    import org.apache.tapestry.engine.ILink;
 19   
 20    /**
 21    * Renders a link using an absolute URL, not simply a URI
 22    * (as with {@link org.apache.tapestry.link.DefaultLinkRenderer}. In addition,
 23    * the scheme, server and port may be changed (this may be appropriate when
 24    * switching between secure and insecure portions of an application).
 25    *
 26    * @author Howard Lewis Ship
 27    * @since 3.0
 28    *
 29    **/
 30   
 31    public class AbsoluteLinkRenderer extends DefaultLinkRenderer
 32    {
 33    private String _scheme;
 34    private String _serverName;
 35    private int _port;
 36   
 37  1 public int getPort()
 38    {
 39  1 return _port;
 40    }
 41   
 42  1 public String getScheme()
 43    {
 44  1 return _scheme;
 45    }
 46   
 47  1 public String getServerName()
 48    {
 49  1 return _serverName;
 50    }
 51   
 52    /**
 53    * Used to override the port in the final URL, if specified. If not specified,
 54    * the port provided by the {@link javax.servlet.ServletRequest#getServerPort() request}
 55    * is used (typically, the value 80).
 56    *
 57    **/
 58   
 59  1 public void setPort(int port)
 60    {
 61  1 _port = port;
 62    }
 63   
 64    /**
 65    * Used to override the scheme in the final URL, if specified. If not specified,
 66    * the scheme provided by the {@link javax.servlet.ServletRequest#getScheme() request}
 67    * is used (typically, <code>http</code>).
 68    *
 69    **/
 70   
 71  1 public void setScheme(String scheme)
 72    {
 73  1 _scheme = scheme;
 74    }
 75   
 76    /**
 77    * Used to override the server name in the final URL, if specified. If not specified,
 78    * the port provided by the {@link javax.servlet.ServletRequest#getServerName() request}
 79    * is used.
 80    *
 81    **/
 82   
 83  1 public void setServerName(String serverName)
 84    {
 85  1 _serverName = serverName;
 86    }
 87   
 88  2 protected String constructURL(ILink link, String anchor, IRequestCycle cycle)
 89    {
 90  2 return link.getAbsoluteURL(_scheme, _serverName, _port, anchor, true);
 91    }
 92   
 93    }