Coverage Report - org.codehaus.plexus.archiver.gzip.PlexusIoGzipResourceCollection
 
Classes in this File Line Coverage Branch Coverage Complexity
PlexusIoGzipResourceCollection
80 %
8/10
N/A
1,333
 
 1  
 package org.codehaus.plexus.archiver.gzip;
 2  
 
 3  
 import java.io.File;
 4  
 import java.io.FileInputStream;
 5  
 import java.io.IOException;
 6  
 import java.io.InputStream;
 7  
 import java.util.HashMap;
 8  
 import java.util.zip.GZIPInputStream;
 9  
 import javax.annotation.Nonnull;
 10  
 import org.codehaus.plexus.archiver.util.Streams;
 11  
 import org.codehaus.plexus.components.io.attributes.FileAttributes;
 12  
 import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes;
 13  
 import org.codehaus.plexus.components.io.resources.PlexusIoCompressedFileResourceCollection;
 14  
 import org.codehaus.plexus.util.IOUtil;
 15  
 
 16  
 /**
 17  
  * Abstract base class for compressed files, aka singleton
 18  
  * resource collections.
 19  
  */
 20  1
 public class PlexusIoGzipResourceCollection
 21  
     extends PlexusIoCompressedFileResourceCollection
 22  
 {
 23  
 
 24  
     @Override
 25  
     protected String getDefaultExtension()
 26  
     {
 27  1
         return ".gz";
 28  
     }
 29  
 
 30  
     @Nonnull
 31  
     @Override
 32  
     protected InputStream getInputStream( File file )
 33  
         throws IOException
 34  
     {
 35  1
         InputStream fis = new FileInputStream( file );
 36  
         try
 37  
         {
 38  1
             InputStream result = Streams.bufferedInputStream( new GZIPInputStream( fis ) );
 39  1
             fis = null;
 40  1
             return result;
 41  
         }
 42  
         finally
 43  0
         {
 44  1
             IOUtil.close( fis );
 45  0
         }
 46  
     }
 47  
 
 48  
     @Override
 49  
     protected PlexusIoResourceAttributes getAttributes( File file )
 50  
         throws IOException
 51  
     {
 52  1
         return new FileAttributes( file, new HashMap<Integer, String>(), new HashMap<Integer, String>() );
 53  
     }
 54  
 
 55  
 }