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
22
23
24
25
26
27
28 @Deprecated(since = "4.0.0")
29 public class DefaultSettingsProblem implements SettingsProblem {
30
31 private final String source;
32
33 private final int lineNumber;
34
35 private final int columnNumber;
36
37 private final String message;
38
39 private final Exception exception;
40
41 private final Severity severity;
42
43
44
45
46
47
48
49
50
51
52
53
54 public DefaultSettingsProblem(
55 String message, Severity severity, String source, int lineNumber, int columnNumber, Exception exception) {
56 this.message = message;
57 this.severity = (severity != null) ? severity : Severity.ERROR;
58 this.source = (source != null) ? source : "";
59 this.lineNumber = lineNumber;
60 this.columnNumber = columnNumber;
61 this.exception = exception;
62 }
63
64 @Override
65 public String getSource() {
66 return source;
67 }
68
69 @Override
70 public int getLineNumber() {
71 return lineNumber;
72 }
73
74 @Override
75 public int getColumnNumber() {
76 return columnNumber;
77 }
78
79 @Override
80 public String getLocation() {
81 StringBuilder buffer = new StringBuilder(256);
82
83 if (!getSource().isEmpty()) {
84 if (buffer.length() > 0) {
85 buffer.append(", ");
86 }
87 buffer.append(getSource());
88 }
89
90 if (getLineNumber() > 0) {
91 if (buffer.length() > 0) {
92 buffer.append(", ");
93 }
94 buffer.append("line ").append(getLineNumber());
95 }
96
97 if (getColumnNumber() > 0) {
98 if (buffer.length() > 0) {
99 buffer.append(", ");
100 }
101 buffer.append("column ").append(getColumnNumber());
102 }
103
104 return buffer.toString();
105 }
106
107 @Override
108 public Exception getException() {
109 return exception;
110 }
111
112 @Override
113 public String getMessage() {
114 String msg;
115
116 if (message != null && !message.isEmpty()) {
117 msg = message;
118 } else {
119 msg = exception.getMessage();
120
121 if (msg == null) {
122 msg = "";
123 }
124 }
125
126 return msg;
127 }
128
129 @Override
130 public Severity getSeverity() {
131 return severity;
132 }
133
134 @Override
135 public String toString() {
136 StringBuilder buffer = new StringBuilder(128);
137
138 buffer.append('[').append(getSeverity()).append("] ");
139 buffer.append(getMessage());
140 String location = getLocation();
141 if (!location.isEmpty()) {
142 buffer.append(" @ ");
143 buffer.append(location);
144 }
145
146 return buffer.toString();
147 }
148 }