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