Coverage Report - org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader
 
Classes in this File Line Coverage Branch Coverage Complexity
ContextClassLoaderResourceLoader
0 %
0/15
0 %
0/6
2,5
 
 1  
 package org.codehaus.plexus.velocity;
 2  
 
 3  
 /*
 4  
  * Copyright 2001-2016 Codehaus 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  
 import java.io.InputStream;
 20  
 
 21  
 import org.apache.velocity.runtime.resource.Resource;
 22  
 import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
 23  
 import org.apache.velocity.runtime.resource.loader.ResourceLoader;
 24  
 import org.apache.velocity.exception.ResourceNotFoundException;
 25  
 
 26  
 import org.apache.commons.collections.ExtendedProperties;
 27  
 
 28  
 /**
 29  
  *
 30  
  * @deprecated use {@link ClasspathResourceLoader}
 31  
  *
 32  
  */
 33  
 @Deprecated
 34  0
 public class ContextClassLoaderResourceLoader
 35  
     extends ResourceLoader
 36  
 {
 37  
     public void init( ExtendedProperties configuration)
 38  
     {
 39  0
     }
 40  
 
 41  
     public synchronized InputStream getResourceStream( String name )
 42  
         throws ResourceNotFoundException
 43  
     {
 44  0
         InputStream result = null;
 45  
 
 46  0
         if (name == null || name.length() == 0)
 47  
         {
 48  0
             throw new ResourceNotFoundException ("No template name provided");
 49  
         }
 50  
 
 51  
         try
 52  
         {
 53  0
             ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
 54  
 
 55  0
             if ( name.startsWith( "/" ) )
 56  
             {
 57  0
                 name = name.substring( 1 );
 58  
             }
 59  
 
 60  0
             result = classLoader.getResourceAsStream( name );
 61  
         }
 62  0
         catch( Exception fnfe )
 63  
         {
 64  0
             throw new ResourceNotFoundException( fnfe.getMessage() );
 65  0
         }
 66  
 
 67  0
         return result;
 68  
     }
 69  
 
 70  
     public boolean isSourceModified(Resource resource)
 71  
     {
 72  0
         return false;
 73  
     }
 74  
 
 75  
     public long getLastModified(Resource resource)
 76  
     {
 77  0
         return 0;
 78  
     }
 79  
 }
 80