Coverage Report - org.apache.maven.plugin.assembly.archive.archiver.PrefixedFileSet
 
Classes in this File Line Coverage Branch Coverage Complexity
PrefixedFileSet
61%
19/31
27%
5/18
2,111
 
 1  
 package org.apache.maven.plugin.assembly.archive.archiver;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *   http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import org.codehaus.plexus.archiver.FileSet;
 23  
 import org.codehaus.plexus.components.io.fileselectors.FileSelector;
 24  
 
 25  
 import java.io.File;
 26  
 
 27  
 /**
 28  
  * @version $Id: PrefixedFileSet.java 999628 2010-09-21 20:41:59Z jdcasey $
 29  
  */
 30  
 public class PrefixedFileSet
 31  
     implements FileSet
 32  
 {
 33  
 
 34  
     private final String rootPrefix;
 35  
 
 36  
     private final FileSet fileSet;
 37  
 
 38  
     private final FileSelector[] selectors;
 39  
 
 40  
     public PrefixedFileSet( final FileSet fileSet, final String rootPrefix, final FileSelector[] selectors )
 41  6
     {
 42  6
         this.fileSet = fileSet;
 43  6
         this.selectors = selectors;
 44  
 
 45  6
         if ( rootPrefix.length() > 0 && !rootPrefix.endsWith( "/" ) )
 46  
         {
 47  0
             this.rootPrefix = rootPrefix + "/";
 48  
         }
 49  
         else
 50  
         {
 51  6
             this.rootPrefix = rootPrefix;
 52  
         }
 53  6
     }
 54  
 
 55  
     public String[] getExcludes()
 56  
     {
 57  3
         return fileSet.getExcludes();
 58  
     }
 59  
 
 60  
     public FileSelector[] getFileSelectors()
 61  
     {
 62  3
         FileSelector[] sel = fileSet.getFileSelectors();
 63  3
         if ( ( sel != null ) && ( selectors != null ) )
 64  
         {
 65  0
             final FileSelector[] temp = new FileSelector[sel.length + selectors.length];
 66  
 
 67  0
             System.arraycopy( sel, 0, temp, 0, sel.length );
 68  0
             System.arraycopy( selectors, 0, temp, sel.length, selectors.length );
 69  
 
 70  0
             sel = temp;
 71  0
         }
 72  3
         else if ( ( sel == null ) && ( selectors != null ) )
 73  
         {
 74  0
             sel = selectors;
 75  
         }
 76  
 
 77  3
         return sel;
 78  
     }
 79  
 
 80  
     public String[] getIncludes()
 81  
     {
 82  3
         return fileSet.getIncludes();
 83  
     }
 84  
 
 85  
     public String getPrefix()
 86  
     {
 87  9
         String prefix = fileSet.getPrefix();
 88  9
         if ( prefix == null )
 89  
         {
 90  9
             return rootPrefix;
 91  
         }
 92  
 
 93  0
         if ( prefix.startsWith( "/" ) )
 94  
         {
 95  0
             if ( prefix.length() > 1 )
 96  
             {
 97  0
                 prefix = prefix.substring( 1 );
 98  
             }
 99  
             else
 100  
             {
 101  0
                 prefix = "";
 102  
             }
 103  
         }
 104  
 
 105  0
         return rootPrefix + prefix;
 106  
     }
 107  
 
 108  
     public boolean isCaseSensitive()
 109  
     {
 110  3
         return fileSet.isCaseSensitive();
 111  
     }
 112  
 
 113  
     public boolean isIncludingEmptyDirectories()
 114  
     {
 115  3
         return fileSet.isIncludingEmptyDirectories();
 116  
     }
 117  
 
 118  
     public boolean isUsingDefaultExcludes()
 119  
     {
 120  3
         return fileSet.isUsingDefaultExcludes();
 121  
     }
 122  
 
 123  
     public File getDirectory()
 124  
     {
 125  9
         return fileSet.getDirectory();
 126  
     }
 127  
 
 128  
 }