Coverage Report - org.apache.maven.plugin.resources.ReflectionProperties
 
Classes in this File Line Coverage Branch Coverage Complexity
ReflectionProperties
93%
13/14
67%
4/6
2,5
 
 1  
 package org.apache.maven.plugin.resources;
 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.project.MavenProject;
 23  
 import org.codehaus.plexus.util.StringUtils;
 24  
 import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
 25  
 
 26  
 import java.util.Properties;
 27  
 
 28  
 /**
 29  
  * @deprecated use classes in the component maven-filtering
 30  
  * TODO remove the class ?
 31  
  * @author Andreas Hoheneder (ahoh_at_inode.at)
 32  
  * @version $Id: ReflectionProperties.java 728546 2008-12-21 22:56:51Z bentmann $
 33  
  */
 34  
 public class ReflectionProperties
 35  
     extends Properties
 36  
 {
 37  
 
 38  
     private MavenProject project;
 39  
 
 40  
     private boolean escapedBackslashesInFilePath;
 41  
 
 42  
     public ReflectionProperties( MavenProject aProject, boolean escapedBackslashesInFilePath )
 43  
     {
 44  2
         super();
 45  
 
 46  2
         project = aProject;
 47  
 
 48  2
         this.escapedBackslashesInFilePath = escapedBackslashesInFilePath;
 49  2
     }
 50  
 
 51  
     public Object get( Object key )
 52  
     {
 53  2
         Object value = null;
 54  
         try
 55  
         {
 56  2
             value = ReflectionValueExtractor.evaluate( "" + key, project );
 57  
 
 58  2
             if ( escapedBackslashesInFilePath && ( value instanceof String ) )
 59  
             {
 60  1
                 String val = (String) value;
 61  
 
 62  
                 // Check if it's a windows path
 63  1
                 if ( val.indexOf( ":\\" ) == 1 )
 64  
                 {
 65  1
                     value = StringUtils.replace( (String) value, "\\", "\\\\" );
 66  1
                     value = StringUtils.replace( (String) value, ":", "\\:" );
 67  
                 }
 68  
             }
 69  
         }
 70  0
         catch ( Exception e )
 71  
         {
 72  
             // TODO: remove the try-catch block when ReflectionValueExtractor.evaluate() throws no more exceptions
 73  2
         }
 74  2
         return value;
 75  
     }
 76  
 }