1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.settings.building;
20
21 import java.util.ArrayList;
22 import java.util.List;
23
24 import org.apache.maven.settings.io.SettingsParseException;
25
26
27
28
29
30 class DefaultSettingsProblemCollector implements SettingsProblemCollector {
31
32 private List<SettingsProblem> problems;
33
34 private String source;
35
36 DefaultSettingsProblemCollector(List<SettingsProblem> problems) {
37 this.problems = (problems != null) ? problems : new ArrayList<>();
38 }
39
40 public List<SettingsProblem> getProblems() {
41 return problems;
42 }
43
44 public void setSource(String source) {
45 this.source = source;
46 }
47
48 @Override
49 public void add(SettingsProblem.Severity severity, String message, int line, int column, Exception cause) {
50 if (line <= 0 && column <= 0 && (cause instanceof SettingsParseException)) {
51 SettingsParseException e = (SettingsParseException) cause;
52 line = e.getLineNumber();
53 column = e.getColumnNumber();
54 }
55
56 SettingsProblem problem = new DefaultSettingsProblem(message, severity, source, line, column, cause);
57
58 problems.add(problem);
59 }
60 }