Coverage Report - org.apache.maven.plugin.assembly.format.ReflectionProperties
 
Classes in this File Line Coverage Branch Coverage Complexity
ReflectionProperties
0%
0/14
0%
0/8
0
 
 1  
 package org.apache.maven.plugin.assembly.format;
 2  
 
 3  
 /*
 4  
  * Copyright 2001-2005 The Apache Software Foundation.
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License");
 7  
  * you may not use this file except in compliance with the License.
 8  
  * You may obtain a copy of the License at
 9  
  *
 10  
  *      http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 
 19  
 import org.apache.maven.project.MavenProject;
 20  
 import org.codehaus.plexus.util.StringUtils;
 21  
 import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
 22  
 
 23  
 import java.util.Properties;
 24  
 
 25  
 /**
 26  
  * @author Andreas Hoheneder (ahoh_at_inode.at)
 27  
  * @version $Id: ReflectionProperties.java 999612 2010-09-21 20:34:50Z jdcasey $
 28  
  * 
 29  
  * @depcrecated
 30  
  */
 31  
 @Deprecated
 32  
 public class ReflectionProperties
 33  
     extends Properties
 34  
 {
 35  
 
 36  
     private static final long serialVersionUID = 1L;
 37  
 
 38  
     private final MavenProject project;
 39  
 
 40  
     boolean escapedBackslashesInFilePath;
 41  
 
 42  
     public ReflectionProperties( final MavenProject aProject, final boolean escapedBackslashesInFilePath )
 43  
     {
 44  0
         super();
 45  
 
 46  0
         project = aProject;
 47  
 
 48  0
         this.escapedBackslashesInFilePath = escapedBackslashesInFilePath;
 49  0
     }
 50  
 
 51  
     @Override
 52  
     public Object get( final Object key )
 53  
     {
 54  0
         Object value = null;
 55  
         try
 56  
         {
 57  0
             value = ReflectionValueExtractor.evaluate( "" + key, project );
 58  
 
 59  0
             if ( escapedBackslashesInFilePath && value != null && "java.lang.String".equals( value.getClass()
 60  
                                                                                                   .getName() ) )
 61  
             {
 62  0
                 final String val = (String) value;
 63  
 
 64  
                 // Check if it's a windows path
 65  0
                 if ( val.indexOf( ":\\" ) == 1 )
 66  
                 {
 67  0
                     value = StringUtils.replace( (String) value, "\\", "\\\\" );
 68  0
                     value = StringUtils.replace( (String) value, ":", "\\:" );
 69  
                 }
 70  
             }
 71  
         }
 72  0
         catch ( final Exception e )
 73  
         {
 74  
             // TODO: remove the try-catch block when ReflectionValueExtractor.evaluate() throws no more exceptions
 75  0
         }
 76  0
         return value;
 77  
     }
 78  
 }