Coverage Report - org.codehaus.plexus.archiver.util.AbstractFileSet
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractFileSet
90%
37/41
N/A
1
 
 1  
 /*
 2  
  * Copyright 2014 The Codehaus Foundation.
 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.util;
 17  
 
 18  
 import javax.annotation.Nonnull;
 19  
 import org.codehaus.plexus.archiver.BaseFileSet;
 20  
 import org.codehaus.plexus.components.io.filemappers.FileMapper;
 21  
 import org.codehaus.plexus.components.io.fileselectors.FileSelector;
 22  
 import org.codehaus.plexus.components.io.functions.InputStreamTransformer;
 23  
 
 24  
 /**
 25  
  * Default implementation of {@link BaseFileSet}.
 26  
  *
 27  
  * @since 1.0-alpha-9
 28  
  */
 29  87
 public abstract class AbstractFileSet<T extends AbstractFileSet>
 30  
     implements BaseFileSet
 31  
 {
 32  
 
 33  
     private String prefix;
 34  
 
 35  
     private String[] includes;
 36  
 
 37  
     private String[] excludes;
 38  
 
 39  
     private FileSelector[] fileSelectors;
 40  
 
 41  87
     private boolean caseSensitive = true;
 42  
 
 43  87
     private boolean usingDefaultExcludes = true;
 44  
 
 45  87
     private boolean includingEmptyDirectories = true;
 46  
 
 47  87
     private InputStreamTransformer streamTransformer = null;
 48  
 
 49  
     private FileMapper[] fileMappers;
 50  
 
 51  
     /**
 52  
      * Sets a string of patterns, which excluded files
 53  
      * should match.
 54  
      */
 55  
     public void setExcludes( String[] excludes )
 56  
     {
 57  68
         this.excludes = excludes;
 58  68
     }
 59  
 
 60  
     @Override
 61  
     public String[] getExcludes()
 62  
     {
 63  87
         return excludes;
 64  
     }
 65  
 
 66  
     /**
 67  
      * Sets a set of file selectors, which should be used
 68  
      * to select the included files.
 69  
      */
 70  
     public void setFileSelectors( FileSelector[] fileSelectors )
 71  
     {
 72  0
         this.fileSelectors = fileSelectors;
 73  0
     }
 74  
 
 75  
     @Override
 76  
     public FileSelector[] getFileSelectors()
 77  
     {
 78  86
         return fileSelectors;
 79  
     }
 80  
 
 81  
     /**
 82  
      * Sets a string of patterns, which included files
 83  
      * should match.
 84  
      */
 85  
     public void setIncludes( String[] includes )
 86  
     {
 87  68
         this.includes = includes;
 88  68
     }
 89  
 
 90  
     @Override
 91  
     public String[] getIncludes()
 92  
     {
 93  87
         return includes;
 94  
     }
 95  
 
 96  
     /**
 97  
      * Sets the prefix, which the file sets contents shall
 98  
      * have.
 99  
      */
 100  
     public void setPrefix( String prefix )
 101  
     {
 102  81
         this.prefix = prefix;
 103  81
     }
 104  
 
 105  
     @Override
 106  
     public String getPrefix()
 107  
     {
 108  87
         return prefix;
 109  
     }
 110  
 
 111  
     /**
 112  
      * Sets, whether the include/exclude patterns are
 113  
      * case sensitive. Defaults to true.
 114  
      */
 115  
     public void setCaseSensitive( boolean caseSensitive )
 116  
     {
 117  0
         this.caseSensitive = caseSensitive;
 118  0
     }
 119  
 
 120  
     @Override
 121  
     public boolean isCaseSensitive()
 122  
     {
 123  86
         return caseSensitive;
 124  
     }
 125  
 
 126  
     /**
 127  
      * Sets, whether the default excludes are being
 128  
      * applied. Defaults to true.
 129  
      */
 130  
     public void setUsingDefaultExcludes( boolean usingDefaultExcludes )
 131  
     {
 132  1
         this.usingDefaultExcludes = usingDefaultExcludes;
 133  1
     }
 134  
 
 135  
     @Override
 136  
     public boolean isUsingDefaultExcludes()
 137  
     {
 138  86
         return usingDefaultExcludes;
 139  
     }
 140  
 
 141  
     /**
 142  
      * Sets, whether empty directories are being included. Defaults
 143  
      * to true.
 144  
      */
 145  
     public void setIncludingEmptyDirectories( boolean includingEmptyDirectories )
 146  
     {
 147  79
         this.includingEmptyDirectories = includingEmptyDirectories;
 148  79
     }
 149  
 
 150  
     @Override
 151  
     public boolean isIncludingEmptyDirectories()
 152  
     {
 153  86
         return includingEmptyDirectories;
 154  
     }
 155  
 
 156  
     public T prefixed( String prefix )
 157  
     {
 158  77
         setPrefix( prefix );
 159  77
         return (T) this;
 160  
     }
 161  
 
 162  
     public T include( String[] includes )
 163  
     {
 164  67
         setIncludes( includes );
 165  67
         return (T) this;
 166  
     }
 167  
 
 168  
     public T exclude( String[] excludes )
 169  
     {
 170  67
         setExcludes( excludes );
 171  67
         return (T) this;
 172  
     }
 173  
 
 174  
     public T includeExclude( String[] includes, String[] excludes )
 175  
     {
 176  66
         return (T) include( includes ).exclude( excludes );
 177  
     }
 178  
 
 179  
     public T includeEmptyDirs( boolean includeEmptyDirectories )
 180  
     {
 181  79
         setIncludingEmptyDirectories( includeEmptyDirectories );
 182  79
         return (T) this;
 183  
     }
 184  
 
 185  
     public void setStreamTransformer( @Nonnull InputStreamTransformer streamTransformer )
 186  
     {
 187  4
         this.streamTransformer = streamTransformer;
 188  4
     }
 189  
 
 190  
     @Override
 191  
     public InputStreamTransformer getStreamTransformer()
 192  
     {
 193  100
         return streamTransformer;
 194  
     }
 195  
 
 196  
     /**
 197  
      * Sets a set of file mappers, which should be used
 198  
      * to change the filename of the included files.
 199  
      */
 200  
     public void setFileMappers( FileMapper[] fileMappers )
 201  
     {
 202  1
         this.fileMappers = fileMappers;
 203  1
     }
 204  
 
 205  
     @Override
 206  
     public FileMapper[] getFileMappers()
 207  
     {
 208  86
         return fileMappers;
 209  
     }
 210  
 
 211  
 }