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