Coverage Report - org.codehaus.plexus.archiver.snappy.SnappyArchiver
 
Classes in this File Line Coverage Branch Coverage Complexity
SnappyArchiver
88 %
16/18
83 %
5/6
2,5
 
 1  
 /**
 2  
  *
 3  
  * Copyright 2004 The Apache Software Foundation
 4  
  *
 5  
  * Licensed under the Apache License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  * http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.codehaus.plexus.archiver.snappy;
 18  
 
 19  
 import java.io.IOException;
 20  
 import org.codehaus.plexus.archiver.AbstractArchiver;
 21  
 import org.codehaus.plexus.archiver.ArchiveEntry;
 22  
 import org.codehaus.plexus.archiver.ArchiverException;
 23  
 import org.codehaus.plexus.archiver.ResourceIterator;
 24  
 import org.codehaus.plexus.archiver.exceptions.EmptyArchiveException;
 25  
 
 26  
 /**
 27  
  * Snappy archiver.
 28  
  */
 29  7
 public class SnappyArchiver
 30  
     extends AbstractArchiver
 31  
 {
 32  
 
 33  7
     private SnappyCompressor compressor = new SnappyCompressor();
 34  
 
 35  
     @Override
 36  
     public void execute()
 37  
         throws ArchiverException, IOException
 38  
     {
 39  7
         if ( !checkForced() )
 40  
         {
 41  1
             return;
 42  
         }
 43  
 
 44  6
         ResourceIterator iter = getResources();
 45  6
         if ( !iter.hasNext() )
 46  
         {
 47  1
             throw new EmptyArchiveException( "archive cannot be empty" );
 48  
         }
 49  5
         ArchiveEntry entry = iter.next();
 50  5
         if ( iter.hasNext() )
 51  
         {
 52  0
             throw new ArchiverException( "There is more than one file in input." );
 53  
         }
 54  5
         compressor.setSource( entry.getResource() );
 55  5
         compressor.setDestFile( getDestFile() );
 56  5
         compressor.compress();
 57  5
     }
 58  
 
 59  
     @Override
 60  
     public boolean isSupportingForced()
 61  
     {
 62  2
         return true;
 63  
     }
 64  
 
 65  
     @Override
 66  
     protected void close()
 67  
     {
 68  7
         compressor.close();
 69  7
     }
 70  
 
 71  
     @Override
 72  
     protected String getArchiveType()
 73  
     {
 74  0
         return "snappy";
 75  
     }
 76  
 
 77  
 }