Coverage Report - org.apache.tapestry5.urlrewriter.SimpleRequestWrapper
 
Classes in this File Line Coverage Branch Coverage Complexity
SimpleRequestWrapper
100%
16/16
N/A
0
 
 1  
 // Copyright 2009 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  
 package org.apache.tapestry5.urlrewriter;
 15  
 
 16  
 import org.apache.tapestry5.ioc.internal.util.Defense;
 17  
 import org.apache.tapestry5.services.DelegatingRequest;
 18  
 import org.apache.tapestry5.services.Request;
 19  
 
 20  
 /**
 21  
  * Class that wraps a {@linkplain Request}. It delegates all methods except ones related to URL
 22  
  * rewriting.
 23  
  */
 24  
 public class SimpleRequestWrapper extends DelegatingRequest
 25  
 {
 26  
 
 27  
     final private String path;
 28  
 
 29  
     final private String serverName;
 30  
 
 31  
     /**
 32  
      * Constructor that receives a request, a server name and a path.
 33  
      * 
 34  
      * @param request
 35  
      *            a {@link Request}. It cannot be null.
 36  
      * @param serverName
 37  
      *            a {@link String}.
 38  
      * @param path
 39  
      *            a {@link String}. It cannot be null.
 40  
      */
 41  
     public SimpleRequestWrapper(Request request, String serverName, String path)
 42  
     {
 43  
         
 44  18
         super(request);
 45  16
         Defense.notNull(serverName, "serverName");
 46  14
         Defense.notNull(path, "path");
 47  
 
 48  12
         this.serverName = serverName;
 49  12
         this.path = path;
 50  
 
 51  12
     }
 52  
 
 53  
     /**
 54  
      * Constructor that receives a request and a path. The server name used is got
 55  
      * from the request.
 56  
      * 
 57  
      * @param request
 58  
      *            a {@link Request}. It cannot be null.
 59  
      * @param path
 60  
      *            a {@link String}. It cannot be null.
 61  
      */
 62  
     public SimpleRequestWrapper(Request request, String path) {
 63  
         
 64  80
         super(request);
 65  
         
 66  78
         Defense.notNull(request, "request");
 67  78
         final String serverName = request.getServerName();
 68  78
         Defense.notNull(serverName, "serverName");
 69  78
         Defense.notNull(path, "path");
 70  
 
 71  76
         this.serverName = serverName;
 72  76
         this.path = path;
 73  
         
 74  76
     }
 75  
     
 76  
     @Override
 77  
     public String getPath()
 78  
     {
 79  216
         return path;
 80  
     }
 81  
 
 82  
     @Override
 83  
     public String getServerName()
 84  
     {
 85  154
         return serverName;
 86  
     }
 87  
 
 88  
 }