Coverage Report - org.codehaus.plexus.archiver.zip.AnonymousResource
 
Classes in this File Line Coverage Branch Coverage Complexity
AnonymousResource
75%
6/8
N/A
1,2
 
 1  
 package org.codehaus.plexus.archiver.zip;
 2  
 
 3  
 import java.io.File;
 4  
 import java.io.IOException;
 5  
 import java.io.InputStream;
 6  
 import java.net.URL;
 7  
 import javax.annotation.Nonnull;
 8  
 import org.codehaus.plexus.components.io.resources.AbstractPlexusIoResource;
 9  
 
 10  
 public class AnonymousResource extends AbstractPlexusIoResource
 11  
 {
 12  
 
 13  
     private final File file;
 14  
 
 15  
     public AnonymousResource( File file )
 16  
     {
 17  152
         this( file, getName( file ) );
 18  152
     }
 19  
 
 20  
     public AnonymousResource( File file, String name )
 21  
     {
 22  152
         super( name, file.lastModified(), file.length(), file.isFile(), file.isDirectory(), file.exists() );
 23  152
         this.file = file;
 24  152
     }
 25  
 
 26  
     @Nonnull
 27  
     @Override
 28  
     public InputStream getContents()
 29  
         throws IOException
 30  
     {
 31  0
         throw new UnsupportedOperationException( "not supp" );
 32  
         // Does this really have an input stream ?
 33  
         //return new FileInputStream( file );
 34  
     }
 35  
 
 36  
     @Override
 37  
     public URL getURL()
 38  
         throws IOException
 39  
     {
 40  0
         return file.toURI().toURL();
 41  
     }
 42  
 
 43  
     private static String getName( File file )
 44  
     {
 45  152
         return file.getPath().replace( '\\', '/' );
 46  
     }
 47  
 
 48  
 }