1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugins.assembly.io;
20
21 import java.util.ArrayList;
22 import java.util.Iterator;
23 import java.util.List;
24
25
26
27
28
29 final class Locator {
30
31 private List<LocatorStrategy> strategies;
32 private final MessageHolder messageHolder;
33
34
35
36
37
38 Locator(List<LocatorStrategy> strategies, MessageHolder messageHolder) {
39 this.messageHolder = messageHolder;
40 this.strategies = new ArrayList<>(strategies);
41 }
42
43
44
45
46 Locator() {
47 this.messageHolder = new DefaultMessageHolder();
48 this.strategies = new ArrayList<>();
49 }
50
51
52
53
54 MessageHolder getMessageHolder() {
55 return messageHolder;
56 }
57
58
59
60
61 void addStrategy(LocatorStrategy strategy) {
62 this.strategies.add(strategy);
63 }
64
65
66
67
68 void removeStrategy(LocatorStrategy strategy) {
69 this.strategies.remove(strategy);
70 }
71
72
73
74
75 void setStrategies(List<LocatorStrategy> strategies) {
76 this.strategies.clear();
77 this.strategies.addAll(strategies);
78 }
79
80
81
82
83 List<LocatorStrategy> getStrategies() {
84 return strategies;
85 }
86
87
88
89
90
91 Location resolve(String locationSpecification) {
92 Location location = null;
93
94 for (Iterator<LocatorStrategy> it = strategies.iterator(); location == null && it.hasNext(); ) {
95 LocatorStrategy strategy = it.next();
96
97 location = strategy.resolve(locationSpecification, messageHolder);
98 }
99
100 return location;
101 }
102 }