Coverage Report - org.apache.maven.shared.io.location.Locator
 
Classes in this File Line Coverage Branch Coverage Complexity
Locator
100 %
23/23
75 %
3/4
1,125
 
 1  
 package org.apache.maven.shared.io.location;
 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.ArrayList;
 23  
 import java.util.Iterator;
 24  
 import java.util.List;
 25  
 
 26  
 import org.apache.maven.shared.io.logging.DefaultMessageHolder;
 27  
 import org.apache.maven.shared.io.logging.MessageHolder;
 28  
 
 29  
 public final class Locator
 30  
 {
 31  
 
 32  
     private List strategies;
 33  
     private final MessageHolder messageHolder;
 34  
 
 35  
     public Locator( List strategies, MessageHolder messageHolder )
 36  3
     {
 37  3
         this.messageHolder = messageHolder;
 38  3
         this.strategies = new ArrayList( strategies );
 39  3
     }
 40  
 
 41  
     public Locator()
 42  4
     {
 43  4
         this.messageHolder = new DefaultMessageHolder();
 44  4
         this.strategies = new ArrayList();
 45  4
     }
 46  
 
 47  
     public MessageHolder getMessageHolder()
 48  
     {
 49  1
         return messageHolder;
 50  
     }
 51  
 
 52  
     public void addStrategy( LocatorStrategy strategy )
 53  
     {
 54  3
         this.strategies.add( strategy );
 55  3
     }
 56  
 
 57  
     public void removeStrategy( LocatorStrategy strategy )
 58  
     {
 59  1
         this.strategies.remove( strategy );
 60  1
     }
 61  
 
 62  
     public void setStrategies( List strategies )
 63  
     {
 64  1
         this.strategies.clear();
 65  1
         this.strategies.addAll( strategies );
 66  1
     }
 67  
 
 68  
     public List getStrategies()
 69  
     {
 70  4
         return strategies;
 71  
     }
 72  
 
 73  
     public Location resolve( String locationSpecification )
 74  
     {
 75  1
         Location location = null;
 76  
 
 77  1
         for ( Iterator it = strategies.iterator(); location == null && it.hasNext(); )
 78  
         {
 79  3
             LocatorStrategy strategy = (LocatorStrategy) it.next();
 80  
 
 81  3
             location = strategy.resolve( locationSpecification, messageHolder );
 82  3
         }
 83  
 
 84  1
         return location;
 85  
     }
 86  
 
 87  
 }