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