1 package org.apache.maven.building;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 /**
23 * Describes a problem that was encountered during settings building. A problem can either be an exception that was
24 * thrown or a simple string message. In addition, a problem carries a hint about its source, e.g. the settings file
25 * that exhibits the problem.
26 *
27 * @author Benjamin Bentmann
28 * @author Robert Scholte
29 */
30 public interface Problem
31 {
32
33 /**
34 * The different severity levels for a problem, in decreasing order.
35 */
36 enum Severity
37 {
38
39 FATAL, //
40 ERROR, //
41 WARNING //
42
43 }
44
45 /**
46 * Gets the hint about the source of the problem. While the syntax of this hint is unspecified and depends on the
47 * creator of the problem, the general expectation is that the hint provides sufficient information to the user to
48 * track the problem back to its origin. A concrete example for such a source hint can be the file path or URL from
49 * which the settings were read.
50 *
51 * @return The hint about the source of the problem or an empty string if unknown, never {@code null}.
52 */
53 String getSource();
54
55 /**
56 * Gets the one-based index of the line containing the problem. The line number should refer to some text file that
57 * is given by {@link #getSource()}.
58 *
59 * @return The one-based index of the line containing the problem or a non-positive value if unknown.
60 */
61 int getLineNumber();
62
63 /**
64 * Gets the one-based index of the column containing the problem. The column number should refer to some text file
65 * that is given by {@link #getSource()}.
66 *
67 * @return The one-based index of the column containing the problem or non-positive value if unknown.
68 */
69 int getColumnNumber();
70
71 /**
72 * Gets the location of the problem. The location is a user-friendly combination of the values from
73 * {@link #getSource()}, {@link #getLineNumber()} and {@link #getColumnNumber()}. The exact syntax of the returned
74 * value is undefined.
75 *
76 * @return The location of the problem, never {@code null}.
77 */
78 String getLocation();
79
80 /**
81 * Gets the exception that caused this problem (if any).
82 *
83 * @return The exception that caused this problem or {@code null} if not applicable.
84 */
85 Exception getException();
86
87 /**
88 * Gets the message that describes this problem.
89 *
90 * @return The message describing this problem, never {@code null}.
91 */
92 String getMessage();
93
94 /**
95 * Gets the severity level of this problem.
96 *
97 * @return The severity level of this problem, never {@code null}.
98 */
99 Severity getSeverity();
100
101 }