2011/08/05 - Jakarta Cactus has been retired.

For more information, please explore the Attic.

Clover coverage report - Cactus 1.8dev for J2EE API 1.3
Coverage timestamp: Sun Mar 26 2006 18:50:18 BRT
file stats: LOC: 91   Methods: 2
NCLOC: 41   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
UrlUtil.java 50% 87.5% 100% 76.9%
coverage coverage
 1   
 /* 
 2   
  * ========================================================================
 3   
  * 
 4   
  * Copyright 2001-2003 The Apache Software Foundation.
 5   
  *
 6   
  * Licensed under the Apache License, Version 2.0 (the "License");
 7   
  * you may not use this file except in compliance with the License.
 8   
  * 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, software
 13   
  * distributed under the License is distributed on an "AS IS" BASIS,
 14   
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15   
  * See the License for the specific language governing permissions and
 16   
  * limitations under the License.
 17   
  * 
 18   
  * ========================================================================
 19   
  */
 20   
 package org.apache.cactus.internal.util;
 21   
 
 22   
 import java.net.URL;
 23   
 
 24   
 /**
 25   
  * Various utility methods for URL manipulation.
 26   
  *
 27   
  * @version $Id: UrlUtil.java 238991 2004-05-22 11:34:50Z vmassol $
 28   
  */
 29   
 public class UrlUtil
 30   
 {
 31   
     /**
 32   
      * Returns the path part of the URL. This method is needed for
 33   
      * JDK 1.2 support as <code>URL.getPath()</code> does not exist in
 34   
      * JDK 1.2 (only for JDK 1.3+).
 35   
      *
 36   
      * @param theURL the URL from which to extract the path
 37   
      * @return the path part of the URL
 38   
      */
 39  48
     public static String getPath(URL theURL)
 40   
     {
 41  48
         String file = theURL.getFile();
 42  48
         String path = null;
 43   
 
 44  48
         if (file != null)
 45   
         {
 46  48
             int q = file.lastIndexOf('?');
 47   
 
 48  48
             if (q != -1)
 49   
             {
 50  48
                 path = file.substring(0, q);
 51   
             }
 52   
             else
 53   
             {
 54  0
                 path = file;
 55   
             }
 56   
         }
 57   
 
 58  48
         return path;
 59   
     }
 60   
 
 61   
     /**
 62   
      * Returns the query string of the URL. This method is needed for
 63   
      * JDK 1.2 support as <code>URL.getQuery()</code> does not exist in
 64   
      * JDK 1.2 (only for JDK 1.3+).
 65   
      *
 66   
      * @param theURL the URL from which to extract the query string
 67   
      * @return the query string portion of the URL
 68   
      */
 69  48
     public static String getQuery(URL theURL)
 70   
     {
 71  48
         String file = theURL.getFile();
 72  48
         String query = null;
 73   
 
 74  48
         if (file != null)
 75   
         {
 76  48
             int q = file.lastIndexOf('?');
 77   
 
 78  48
             if (q != -1)
 79   
             {
 80  48
                 query = file.substring(q + 1);
 81   
             }
 82   
             else
 83   
             {
 84  0
                 query = "";
 85   
             }
 86   
         }
 87   
 
 88  48
         return query;
 89   
     }
 90   
 }
 91