1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.internal.impl;
20
21 import org.apache.maven.api.services.BuilderProblem;
22
23
24
25
26
27
28 class DefaultBuilderProblem implements BuilderProblem {
29 final String source;
30 final int lineNumber;
31 final int columnNumber;
32 final Exception exception;
33 final String message;
34 final Severity severity;
35
36 DefaultBuilderProblem(
37 String source, int lineNumber, int columnNumber, Exception exception, String message, Severity severity) {
38 this.source = source;
39 this.lineNumber = lineNumber;
40 this.columnNumber = columnNumber;
41 this.exception = exception;
42 this.message = message;
43 this.severity = severity;
44 }
45
46 @Override
47 public String getSource() {
48 return source;
49 }
50
51 @Override
52 public int getLineNumber() {
53 return lineNumber;
54 }
55
56 @Override
57 public int getColumnNumber() {
58 return columnNumber;
59 }
60
61 @Override
62 public Exception getException() {
63 return exception;
64 }
65
66 @Override
67 public String getMessage() {
68 return message;
69 }
70
71 @Override
72 public Severity getSeverity() {
73 return severity;
74 }
75
76 @Override
77 public String getLocation() {
78 StringBuilder buffer = new StringBuilder(256);
79 if (getSource() != null && !getSource().isEmpty()) {
80 buffer.append(getSource());
81 }
82 if (getLineNumber() > 0) {
83 if (!buffer.isEmpty()) {
84 buffer.append(", ");
85 }
86 buffer.append("line ").append(getLineNumber());
87 }
88 if (getColumnNumber() > 0) {
89 if (!buffer.isEmpty()) {
90 buffer.append(", ");
91 }
92 buffer.append("column ").append(getColumnNumber());
93 }
94 return buffer.toString();
95 }
96
97 @Override
98 public String toString() {
99 StringBuilder buffer = new StringBuilder(128);
100 buffer.append('[').append(severity).append("]");
101 String msg = message != null ? message : exception != null ? exception.getMessage() : null;
102 if (msg != null && !msg.isEmpty()) {
103 buffer.append(" ").append(msg);
104 }
105 String location = getLocation();
106 if (!location.isEmpty()) {
107 buffer.append(" @ ").append(location);
108 }
109 return buffer.toString();
110 }
111 }