1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.model.building;
20
21 import org.apache.maven.model.Model;
22
23
24
25
26
27
28
29
30 public class DefaultModelProblem implements ModelProblem {
31
32 private final String source;
33
34 private final int lineNumber;
35
36 private final int columnNumber;
37
38 private final String modelId;
39
40 private final String message;
41
42 private final Exception exception;
43
44 private final Severity severity;
45
46 private final Version version;
47
48
49
50
51
52
53
54
55
56
57
58
59
60 public DefaultModelProblem(
61 String message,
62 Severity severity,
63 Version version,
64 Model source,
65 int lineNumber,
66 int columnNumber,
67 Exception exception) {
68 this(
69 message,
70 severity,
71 version,
72 ModelProblemUtils.toPath(source),
73 lineNumber,
74 columnNumber,
75 ModelProblemUtils.toId(source),
76 exception);
77 }
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93 @SuppressWarnings("checkstyle:parameternumber")
94 public DefaultModelProblem(
95 String message,
96 Severity severity,
97 Version version,
98 String source,
99 int lineNumber,
100 int columnNumber,
101 String modelId,
102 Exception exception) {
103 this.message = message;
104 this.severity = (severity != null) ? severity : Severity.ERROR;
105 this.source = (source != null) ? source : "";
106 this.lineNumber = lineNumber;
107 this.columnNumber = columnNumber;
108 this.modelId = (modelId != null) ? modelId : "";
109 this.exception = exception;
110 this.version = version;
111 }
112
113 @Override
114 public String getSource() {
115 return source;
116 }
117
118 @Override
119 public int getLineNumber() {
120 return lineNumber;
121 }
122
123 @Override
124 public int getColumnNumber() {
125 return columnNumber;
126 }
127
128 @Override
129 public String getModelId() {
130 return modelId;
131 }
132
133 @Override
134 public Exception getException() {
135 return exception;
136 }
137
138 @Override
139 public String getMessage() {
140 String msg;
141
142 if (message != null && message.length() > 0) {
143 msg = message;
144 } else {
145 msg = exception.getMessage();
146
147 if (msg == null) {
148 msg = "";
149 }
150 }
151
152 return msg;
153 }
154
155 @Override
156 public Severity getSeverity() {
157 return severity;
158 }
159
160 @Override
161 public Version getVersion() {
162 return version;
163 }
164
165 @Override
166 public String toString() {
167 StringBuilder buffer = new StringBuilder(128);
168
169 buffer.append('[').append(getSeverity()).append("] ");
170 buffer.append(getMessage());
171 buffer.append(" @ ").append(ModelProblemUtils.formatLocation(this, null));
172
173 return buffer.toString();
174 }
175 }