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