Coverage Report - org.apache.maven.plugin.toolchain.ToolchainConverter
 
Classes in this File Line Coverage Branch Coverage Complexity
ToolchainConverter
0%
0/22
0%
0/6
2.333
 
 1  
 package org.apache.maven.plugin.toolchain;
 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 java.util.HashMap;
 23  
 import java.util.Map;
 24  
 
 25  
 import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
 26  
 import org.codehaus.plexus.component.configurator.ConfigurationListener;
 27  
 import org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter;
 28  
 import org.codehaus.plexus.component.configurator.converters.ConfigurationConverter;
 29  
 import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup;
 30  
 import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
 31  
 import org.codehaus.plexus.configuration.PlexusConfiguration;
 32  
 import org.codehaus.plexus.configuration.PlexusConfigurationException;
 33  
 
 34  
 /**
 35  
  * Plexus ConfigurationConverter
 36  
  *
 37  
  * @author mkleint
 38  
  */
 39  0
 public class ToolchainConverter
 40  
     extends AbstractConfigurationConverter
 41  
 {
 42  
 
 43  0
     public static final String ROLE = ConfigurationConverter.class.getName();
 44  
 
 45  
     /**
 46  
      * @see org.codehaus.plexus.component.configurator.converters.ConfigurationConverter#canConvert(java.lang.Class)
 47  
      */
 48  
     public boolean canConvert( Class type )
 49  
     {
 50  0
         return Toolchains.class.isAssignableFrom( type );
 51  
     }
 52  
 
 53  
     /**
 54  
      * @see org.codehaus.plexus.component.configurator.converters.ConfigurationConverter#fromConfiguration(org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup, org.codehaus.plexus.configuration.PlexusConfiguration, java.lang.Class, java.lang.Class, java.lang.ClassLoader, org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator, org.codehaus.plexus.component.configurator.ConfigurationListener)
 55  
      */
 56  
     public Object fromConfiguration( ConverterLookup converterLookup,
 57  
                                      PlexusConfiguration configuration,
 58  
                                      Class type, Class baseType,
 59  
                                      ClassLoader classLoader,
 60  
                                      ExpressionEvaluator expressionEvaluator,
 61  
                                      ConfigurationListener listener )
 62  
         throws ComponentConfigurationException
 63  
     {
 64  0
         Toolchains retValue = new Toolchains();
 65  0
         processConfiguration( retValue, configuration, expressionEvaluator );
 66  
 
 67  0
         return retValue;
 68  
     }
 69  
 
 70  
     private void processConfiguration( Toolchains chain,
 71  
                                        PlexusConfiguration configuration,
 72  
                                        ExpressionEvaluator expressionEvaluator )
 73  
         throws ComponentConfigurationException
 74  
     {
 75  0
         Map map = new HashMap();
 76  0
         PlexusConfiguration[] tools = configuration.getChildren();
 77  0
         for ( int i = 0; i < tools.length; i++ )
 78  
         {
 79  0
             String type = tools[i].getName();
 80  0
             PlexusConfiguration[] params = tools[i].getChildren();
 81  0
             Map parameters = new HashMap();
 82  0
             for ( int j = 0; j < params.length; j++ )
 83  
             {
 84  
                 try
 85  
                 {
 86  0
                     String name = params[j].getName();
 87  0
                     String val = params[j].getValue();
 88  0
                     parameters.put( name, val );
 89  
                 }
 90  0
                 catch ( PlexusConfigurationException ex )
 91  
                 {
 92  0
                     throw new ComponentConfigurationException( ex );
 93  0
                 }
 94  
             }
 95  0
             map.put( type, parameters );
 96  
         }
 97  0
         chain.toolchains = map;
 98  0
     }
 99  
 }