Coverage Report - org.apache.maven.shared.filtering.AbstractMavenFilteringRequest
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractMavenFilteringRequest
78%
48/61
0%
0/4
1.069
 
 1  
 package org.apache.maven.shared.filtering;
 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.apache.maven.execution.MavenSession;
 23  
 import org.apache.maven.project.MavenProject;
 24  
 
 25  
 import java.util.ArrayList;
 26  
 import java.util.LinkedHashSet;
 27  
 import java.util.List;
 28  
 import java.util.Properties;
 29  
 import java.util.Set;
 30  
 
 31  
 /**
 32  
  * @since 1.0-beta-3
 33  
  */
 34  
 public class AbstractMavenFilteringRequest
 35  
 {
 36  
 
 37  
     private MavenProject mavenProject;
 38  
 
 39  
     private List<String> filters;
 40  
 
 41  28
     private boolean escapeWindowsPaths = true;
 42  
 
 43  
     private String encoding;
 44  
 
 45  
     private MavenSession mavenSession;
 46  
 
 47  
     /** 
 48  
      * List of Strings considered as expressions which contains values in the project/pom:
 49  
      * pom project
 50  
      * Default value will be pom and project.
 51  
      *
 52  
      * @since 1.0-beta-2
 53  
      */
 54  28
     private List<String> projectStartExpressions = new ArrayList<String>();
 55  
     
 56  
     /**
 57  
      * String which will escape interpolation mechanism:
 58  
      * foo \${foo.bar} -> foo ${foo.bar}
 59  
      *
 60  
      * @since 1.0-beta-2
 61  
      */
 62  
     private String escapeString;
 63  
     
 64  
     /**
 65  
      * @since 1.0-beta-3
 66  
      */
 67  
     private Properties additionalProperties;
 68  
     
 69  
     /**
 70  
      * @since 1.0-beta-3
 71  
      */
 72  28
     private boolean injectProjectBuildFilters = false;
 73  
     
 74  
     /**
 75  
      * Set of expression delimiter specifications to use during filtering. Delimiter specifications are
 76  
      * given in the form 'BEGIN*END' or, for symmetrical delimiters, simply 'TOKEN'. The default
 77  
      * values are '${*}' and '@'.
 78  
      * 
 79  
      * @since 1.0-beta-3
 80  
      */
 81  28
     private LinkedHashSet<String> delimiters = new LinkedHashSet<String>();
 82  
     
 83  
     /**
 84  
      * Do not stop trying to filter tokens when reaching EOL.
 85  
      *
 86  
      * @since 1.0
 87  
      */
 88  
     private boolean supportMultiLineFiltering;
 89  
     
 90  
     protected AbstractMavenFilteringRequest()
 91  3
     {
 92  3
         initDefaults();
 93  3
     }
 94  
 
 95  
     protected AbstractMavenFilteringRequest( MavenProject mavenProject, List<String> filters,
 96  
                                              String encoding, MavenSession mavenSession )
 97  25
     {
 98  25
         initDefaults();
 99  25
         this.mavenProject = mavenProject;
 100  25
         this.filters = filters;
 101  25
         this.encoding = encoding;
 102  25
         this.mavenSession = mavenSession;
 103  25
     }
 104  
 
 105  
     private void initDefaults()
 106  
     {
 107  28
         projectStartExpressions.add( "pom" );
 108  28
         projectStartExpressions.add( "project" );
 109  
         
 110  28
         delimiters.add( "${*}" );
 111  28
         delimiters.add( "@" );
 112  28
     }
 113  
 
 114  
     public MavenProject getMavenProject()
 115  
     {
 116  193
         return mavenProject;
 117  
     }
 118  
 
 119  
     public void setMavenProject( MavenProject mavenProject )
 120  
     {
 121  3
         this.mavenProject = mavenProject;
 122  3
     }
 123  
 
 124  
     public List<String> getFilters()
 125  
     {
 126  55
         return filters;
 127  
     }
 128  
 
 129  
     public void setFilters( List<String> filters )
 130  
     {
 131  3
         this.filters = filters;
 132  3
     }
 133  
 
 134  
     public List<String> getFileFilters()
 135  
     {
 136  55
         return getFilters();
 137  
     }
 138  
 
 139  
     public void setFileFilters( List<String> filters )
 140  
     {
 141  2
         setFilters( filters );
 142  2
     }
 143  
 
 144  
     /**
 145  
      * @since 1.0-beta-3
 146  
      */
 147  
     public boolean isEscapeWindowsPaths()
 148  
     {
 149  28
         return escapeWindowsPaths;
 150  
     }
 151  
 
 152  
     /**
 153  
      * @since 1.0-beta-3
 154  
      */
 155  
     public void setEscapeWindowsPaths( boolean escapedBackslashesInFilePath )
 156  
     {
 157  3
         this.escapeWindowsPaths = escapedBackslashesInFilePath;
 158  3
     }
 159  
     
 160  
     public boolean isEscapedBackslashesInFilePath()
 161  
     {
 162  0
         return isEscapeWindowsPaths();
 163  
     }
 164  
     
 165  
     public void setEscapedBackslashesInFilePath( boolean escape )
 166  
     {
 167  1
         setEscapeWindowsPaths( escape );
 168  1
     }
 169  
 
 170  
     public String getEncoding()
 171  
     {
 172  146
         return encoding;
 173  
     }
 174  
 
 175  
     public void setEncoding( String encoding )
 176  
     {
 177  0
         this.encoding = encoding;
 178  0
     }
 179  
 
 180  
     public MavenSession getMavenSession()
 181  
     {
 182  138
         return mavenSession;
 183  
     }
 184  
 
 185  
     public void setMavenSession( MavenSession mavenSession )
 186  
     {
 187  3
         this.mavenSession = mavenSession;
 188  3
     }
 189  
 
 190  
     /**
 191  
      * @since 1.0-beta-3
 192  
      */
 193  
     public Properties getAdditionalProperties()
 194  
     {
 195  29
         return additionalProperties;
 196  
     }
 197  
 
 198  
     /**
 199  
      * @since 1.0-beta-3
 200  
      */
 201  
     public void setAdditionalProperties( Properties additionalProperties )
 202  
     {
 203  1
         this.additionalProperties = additionalProperties;
 204  1
     }
 205  
 
 206  
     /**
 207  
      * @since 1.0-beta-3
 208  
      */
 209  
     public boolean isInjectProjectBuildFilters()
 210  
     {
 211  27
         return injectProjectBuildFilters;
 212  
     }
 213  
 
 214  
     /**
 215  
      * @since 1.0-beta-3
 216  
      */
 217  
     public void setInjectProjectBuildFilters( boolean injectProjectBuildFilters )
 218  
     {
 219  2
         this.injectProjectBuildFilters = injectProjectBuildFilters;
 220  2
     }
 221  
 
 222  
     /**
 223  
      * @since 1.0-beta-2
 224  
      */
 225  
     public String getEscapeString()
 226  
     {
 227  28
         return escapeString;
 228  
     }
 229  
 
 230  
     /**
 231  
      * @param escapeString
 232  
      * @since 1.0-beta-2
 233  
      */
 234  
     public void setEscapeString( String escapeString )
 235  
     {
 236  5
         this.escapeString = escapeString;
 237  5
     }
 238  
     
 239  
     /**
 240  
      * @since 1.0-beta-2
 241  
      */
 242  
     public List getProjectStartExpressions()
 243  
     {
 244  29
         return projectStartExpressions;
 245  
     }
 246  
 
 247  
     /**
 248  
      * @param projectStartExpressions
 249  
      * @since 1.0-beta-2
 250  
      */
 251  
     public void setProjectStartExpressions( List projectStartExpressions )
 252  
     {
 253  0
         this.projectStartExpressions = projectStartExpressions;
 254  0
     }
 255  
 
 256  
     /**
 257  
      * See {@link AbstractMavenFilteringRequest#delimiters} for more information and default values.
 258  
      *
 259  
      * @return Not allowed to be <code>null</code> or empty.
 260  
      * @since 1.0-beta-3
 261  
      */
 262  
     public LinkedHashSet<String> getDelimiters()
 263  
     {
 264  56
         return delimiters;
 265  
     }
 266  
 
 267  
     /**
 268  
      * Set the delimiter specifications to use during filtering. Specifications should be of the form:
 269  
      * 'BEGIN*END' for asymmetrical delimiters, or 'TOKEN' for symmetrical delimiters. See
 270  
      * {@link AbstractMavenFilteringRequest#delimiters} for more information and default values.
 271  
      * 
 272  
      * @param delimiters If <code>null</code>, reset delimiters to '${*}' only. Otherwise, use the provided value.
 273  
      * @since 1.0-beta-3
 274  
      */
 275  
     public void setDelimiters( LinkedHashSet<String> delimiters )
 276  
     {
 277  0
         if ( delimiters == null || delimiters.isEmpty() )
 278  
         {
 279  0
             this.delimiters.clear();
 280  0
             this.delimiters.add( "${*}" );
 281  
         }
 282  
         else
 283  
         {
 284  0
             this.delimiters = delimiters;
 285  
         }
 286  0
     }
 287  
 
 288  
     public boolean isSupportMultiLineFiltering()
 289  
     {
 290  0
         return supportMultiLineFiltering;
 291  
     }
 292  
 
 293  
     public void setSupportMultiLineFiltering( boolean supportMultiLineFiltering )
 294  
     {
 295  0
         this.supportMultiLineFiltering = supportMultiLineFiltering;
 296  0
     }
 297  
 
 298  
 }