Coverage Report - org.codehaus.plexus.archiver.snappy.PlexusIoSnappyResourceCollection
 
Classes in this File Line Coverage Branch Coverage Complexity
PlexusIoSnappyResourceCollection
100%
8/8
N/A
1,333
 
 1  
 package org.codehaus.plexus.archiver.snappy;
 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 javax.annotation.Nonnull;
 9  
 import javax.annotation.WillNotClose;
 10  
 import org.codehaus.plexus.components.io.attributes.FileAttributes;
 11  
 import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes;
 12  
 import org.codehaus.plexus.components.io.resources.PlexusIoCompressedFileResourceCollection;
 13  
 import org.codehaus.plexus.util.IOUtil;
 14  
 
 15  
 /**
 16  
  * Implementation of {@link org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection} for
 17  
  * snappy compressed files.
 18  
  */
 19  1
 public class PlexusIoSnappyResourceCollection
 20  
     extends PlexusIoCompressedFileResourceCollection
 21  
 {
 22  
 
 23  
     @Nonnull
 24  
     @Override
 25  
     protected @WillNotClose
 26  
     InputStream getInputStream( File file )
 27  
         throws IOException
 28  
     {
 29  1
         InputStream fis = new FileInputStream( file );
 30  
         try
 31  
         {
 32  1
             final InputStream result = SnappyUnArchiver.getSnappyInputStream( fis );
 33  1
             fis = null;
 34  1
             return result;
 35  
         }
 36  
         finally
 37  
         {
 38  1
             IOUtil.close( fis );
 39  
         }
 40  
     }
 41  
 
 42  
     @Override protected PlexusIoResourceAttributes getAttributes( File file ) throws IOException
 43  
     {
 44  1
         return new FileAttributes( file, new HashMap<Integer, String>(), new HashMap<Integer, String>() );
 45  
     }
 46  
 
 47  
     @Override
 48  
     protected String getDefaultExtension()
 49  
     {
 50  1
         return ".snappy";
 51  
     }
 52  
 
 53  
 }