Coverage Report - org.apache.myfaces.shared.webapp.webxml.ServletMapping
 
Classes in this File Line Coverage Branch Coverage Complexity
ServletMapping
84%
16/19
80%
8/10
1.571
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *   http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 package org.apache.myfaces.shared.webapp.webxml;
 20  
 
 21  
 public class ServletMapping
 22  
 {
 23  
     private final String _servletName;
 24  
     private final Class _servletClass;
 25  
     private final String _urlPattern;
 26  
     private final String _extension;
 27  
     private final String _prefix;
 28  
 
 29  
     public ServletMapping(String servletName, Class servletClass, String urlPattern)
 30  2
     {
 31  2
         _servletName = servletName;
 32  2
         _servletClass = servletClass;
 33  2
         _urlPattern = urlPattern;
 34  2
         _extension = _urlPattern != null && _urlPattern.startsWith("*.") ? _urlPattern.substring(_urlPattern
 35  
                 .indexOf('.')) : null;
 36  2
         if (_extension == null)
 37  
         {
 38  1
             int index = _urlPattern.indexOf("/*");
 39  1
             if (index != -1)
 40  
             {
 41  1
                 _prefix = _urlPattern.substring(0, _urlPattern.indexOf("/*"));
 42  
             }
 43  
             else
 44  
             {
 45  0
                 _prefix = _urlPattern;
 46  
             }
 47  1
         }
 48  
         else
 49  
         {
 50  1
             _prefix = null;
 51  
         }
 52  2
     }
 53  
 
 54  
     public boolean isExtensionMapping()
 55  
     {
 56  2
         return _extension != null;
 57  
     }
 58  
 
 59  
     public String getExtension()
 60  
     {
 61  1
         return _extension;
 62  
     }
 63  
 
 64  
     public String getPrefix()
 65  
     {
 66  1
         return _prefix;
 67  
     }
 68  
 
 69  
     public String getServletName()
 70  
     {
 71  0
         return _servletName;
 72  
     }
 73  
 
 74  
     public Class getServletClass()
 75  
     {
 76  0
         return _servletClass;
 77  
     }
 78  
 
 79  
     public String getUrlPattern()
 80  
     {
 81  2
         return _urlPattern;
 82  
     }
 83  
 }