##### Coverage Report - org.apache.maven.shared.io.location.Locator

Classes in this File | Line Coverage | Branch Coverage | Complexity
Locator |
100% | 22/22
100% | 1/1
| 1.125;1.125

1 |  |
     package org.apache.maven.shared.io.location;
2 |  |
3 |  |
     import java.util.ArrayList;
4 |  |
     import java.util.Iterator;
5 |  |
     import java.util.List;
6 |  |
7 |  |
     import org.apache.maven.shared.io.logging.DefaultMessageHolder;
8 |  |
     import org.apache.maven.shared.io.logging.MessageHolder;
9 |  |
10 |  |
     public final class Locator
11 |  |
     {
12 |  |
13 |  |
         private List strategies;
14 |  |
         private final MessageHolder messageHolder;
15 |  |
16 | 3 |
         public Locator( List strategies, MessageHolder messageHolder )
17 |  |
         {
18 | 3 |
             this.messageHolder = messageHolder;
19 | 3 |
             this.strategies = new ArrayList( strategies );
20 | 3 |
         }
21 |  |
22 | 4 |
         public Locator()
23 |  |
         {
24 | 4 |
             this.messageHolder = new DefaultMessageHolder();
25 | 4 |
             this.strategies = new ArrayList();
26 | 4 |
         }
27 |  |
28 |  |
         public MessageHolder getMessageHolder()
29 |  |
         {
30 | 1 |
             return messageHolder;
31 |  |
         }
32 |  |
33 |  |
         public void addStrategy( LocatorStrategy strategy )
34 |  |
         {
35 | 3 |
             this.strategies.add( strategy );
36 | 3 |
         }
37 |  |
38 |  |
         public void removeStrategy( LocatorStrategy strategy )
39 |  |
         {
40 | 1 |
             this.strategies.remove( strategy );
41 | 1 |
         }
42 |  |
43 |  |
         public void setStrategies( List strategies )
44 |  |
         {
45 | 1 |
             this.strategies.clear();
46 | 1 |
             this.strategies.addAll( strategies );
47 | 1 |
         }
48 |  |
49 |  |
         public List getStrategies()
50 |  |
         {
51 | 4 |
             return strategies;
52 |  |
         }
53 |  |
54 |  |
         public Location resolve( String locationSpecification )
55 |  |
         {
56 | 1 |
             Location location = null;
57 |  |
58 | 5 |
             for ( Iterator it = strategies.iterator(); location == null && it.hasNext(); )
59 |  |
             {
60 | 3 |
                 LocatorStrategy strategy = (LocatorStrategy) it.next();
61 |  |
62 | 3 |
                 location = strategy.resolve( locationSpecification, messageHolder );
63 |  |
             }
64 |  |
65 | 1 |
             return location;
66 |  |
         }
67 |  |
68 |  |
     }