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