Coverage Report - org.codehaus.plexus.classworlds.strategy.AbstractStrategy
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractStrategy
92 %
13/14
100 %
4/4
1,4
 
 1  
 package org.codehaus.plexus.classworlds.strategy;
 2  
 
 3  
 import java.net.URL;
 4  
 import java.util.Collection;
 5  
 import java.util.Collections;
 6  
 import java.util.Enumeration;
 7  
 import java.util.LinkedHashSet;
 8  
 
 9  
 import org.codehaus.plexus.classworlds.UrlUtils;
 10  
 import org.codehaus.plexus.classworlds.realm.ClassRealm;
 11  
 
 12  
 /*
 13  
  * Copyright 2001-2006 Codehaus Foundation.
 14  
  *
 15  
  * Licensed under the Apache License, Version 2.0 (the "License");
 16  
  * you may not use this file except in compliance with the License.
 17  
  * You may obtain a copy of the License at
 18  
  *
 19  
  *      http://www.apache.org/licenses/LICENSE-2.0
 20  
  *
 21  
  * Unless required by applicable law or agreed to in writing, software
 22  
  * distributed under the License is distributed on an "AS IS" BASIS,
 23  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 24  
  * See the License for the specific language governing permissions and
 25  
  * limitations under the License.
 26  
  */
 27  
 
 28  
 /**
 29  
  * @author Jason van Zyl
 30  
  */
 31  
 public abstract class AbstractStrategy
 32  
     implements Strategy    
 33  
 {
 34  
 
 35  
     protected ClassRealm realm;
 36  
 
 37  
     public AbstractStrategy( ClassRealm realm )
 38  303
     {
 39  303
         this.realm = realm;
 40  303
     }
 41  
 
 42  
     protected String getNormalizedResource( String name )
 43  
     {
 44  0
         return UrlUtils.normalizeUrlPath( name );
 45  
     }
 46  
 
 47  
     protected Enumeration<URL> combineResources( Enumeration<URL> en1, Enumeration<URL> en2, Enumeration<URL> en3 )
 48  
     {
 49  13
         Collection<URL> urls = new LinkedHashSet<URL>();
 50  
 
 51  13
         addAll( urls, en1 );
 52  13
         addAll( urls, en2 );
 53  13
         addAll( urls, en3 );
 54  
 
 55  13
         return Collections.enumeration( urls );
 56  
     }
 57  
 
 58  
     private void addAll( Collection<URL> target, Enumeration<URL> en )
 59  
     {
 60  39
         if ( en != null )
 61  
         {
 62  30
             while ( en.hasMoreElements() )
 63  
             {
 64  13
                 target.add( en.nextElement() );
 65  
             }
 66  
         }
 67  39
     }
 68  
 
 69  
     public ClassRealm getRealm()
 70  
     {
 71  2
         return realm;
 72  
     }
 73  
 
 74  
 }