Coverage report

  %line %branch
org.apache.jetspeed.profiler.rules.impl.DomainCriterionResolver
0% 
0% 

 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  * 
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  * 
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.jetspeed.profiler.rules.impl;
 18  
 
 19  
 import org.apache.jetspeed.profiler.rules.RuleCriterion;
 20  
 import org.apache.jetspeed.profiler.rules.RuleCriterionResolver;
 21  
 import org.apache.jetspeed.request.RequestContext;
 22  
 
 23  
 /**
 24  
  * Hostname Resolver
 25  
  * 
 26  
  * @author <a href="mailto:stalherm@goodgulf.net">Frank Stalherm</a>
 27  
  * @version $Id:$
 28  
  */
 29  0
 public class DomainCriterionResolver extends StandardResolver implements
 30  
         RuleCriterionResolver
 31  
 {
 32  
 
 33  
     /*
 34  
      * (non-Javadoc)
 35  
      * 
 36  
      * @see org.apache.jetspeed.profiler.rules.impl.StandardResolver#isControl(org.apache.jetspeed.profiler.rules.RuleCriterion)
 37  
      */
 38  
     public boolean isControl(RuleCriterion criterion)
 39  
     {
 40  0
         return false;
 41  
     }
 42  
 
 43  
     /*
 44  
      * (non-Javadoc)
 45  
      * 
 46  
      * @see org.apache.jetspeed.profiler.rules.impl.StandardResolver#isNavigation(org.apache.jetspeed.profiler.rules.RuleCriterion)
 47  
      */
 48  
     public boolean isNavigation(RuleCriterion criterion)
 49  
     {
 50  0
         return true;
 51  
     }
 52  
 
 53  
     public String resolve(RequestContext context, RuleCriterion criterion)
 54  
     {
 55  0
         return getDomain(context.getRequest().getServerName());
 56  
     }
 57  
 
 58  
     /**
 59  
      * extracts the domain from the servername from RequestContext
 60  
      * 
 61  
      * @param servername
 62  
      *            server name from request
 63  
      * @return domain extracted from server name
 64  
      */
 65  
     public static String getDomain(String servername)
 66  
     {
 67  0
         String domain = null;
 68  
 
 69  0
         if (servername != null)
 70  
         {
 71  0
             int idx = servername.indexOf(".");
 72  0
             if (idx != -1)
 73  
             {
 74  0
                 domain = servername.substring(idx + 1, servername.length());
 75  
             } else
 76  
             {
 77  
                 // maybe there is no domain
 78  
                 // testing for IPv6 IP Address
 79  0
                 idx = servername.indexOf(":");
 80  0
                 if (idx != -1)
 81  
                 {
 82  
                     // TODO resolving IP Address?
 83  
                     // no domain is available
 84  0
                     domain = "";
 85  
                 } else
 86  
                 {
 87  
                     // no domain is available
 88  0
                     domain = "";
 89  
                 }
 90  
             }
 91  
         }
 92  0
         return domain;
 93  
     }
 94  
 
 95  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.