| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.yaml.snakeyaml.error; |
| 17 | |
|
| 18 | |
public class MarkedYAMLException extends YAMLException { |
| 19 | |
|
| 20 | |
private static final long serialVersionUID = -9119388488683035101L; |
| 21 | |
private String context; |
| 22 | |
private Mark contextMark; |
| 23 | |
private String problem; |
| 24 | |
private Mark problemMark; |
| 25 | |
private String note; |
| 26 | |
|
| 27 | |
protected MarkedYAMLException(String context, Mark contextMark, String problem, |
| 28 | |
Mark problemMark, String note) { |
| 29 | 77 | this(context, contextMark, problem, problemMark, note, null); |
| 30 | 77 | } |
| 31 | |
|
| 32 | |
protected MarkedYAMLException(String context, Mark contextMark, String problem, |
| 33 | |
Mark problemMark, String note, Throwable cause) { |
| 34 | 190 | super(context + "; " + problem + "; " + problemMark, cause); |
| 35 | 190 | this.context = context; |
| 36 | 190 | this.contextMark = contextMark; |
| 37 | 190 | this.problem = problem; |
| 38 | 190 | this.problemMark = problemMark; |
| 39 | 190 | this.note = note; |
| 40 | 190 | } |
| 41 | |
|
| 42 | |
protected MarkedYAMLException(String context, Mark contextMark, String problem, Mark problemMark) { |
| 43 | 14 | this(context, contextMark, problem, problemMark, null, null); |
| 44 | 14 | } |
| 45 | |
|
| 46 | |
protected MarkedYAMLException(String context, Mark contextMark, String problem, |
| 47 | |
Mark problemMark, Throwable cause) { |
| 48 | 61 | this(context, contextMark, problem, problemMark, null, cause); |
| 49 | 61 | } |
| 50 | |
|
| 51 | |
@Override |
| 52 | |
public String toString() { |
| 53 | 17 | StringBuilder lines = new StringBuilder(); |
| 54 | 17 | if (context != null) { |
| 55 | 11 | lines.append(context); |
| 56 | 11 | lines.append("\n"); |
| 57 | |
} |
| 58 | 17 | if (contextMark != null |
| 59 | |
&& (problem == null || problemMark == null |
| 60 | |
|| (contextMark.getName().equals(problemMark.getName())) |
| 61 | |
|| (contextMark.getLine() != problemMark.getLine()) || (contextMark |
| 62 | |
.getColumn() != problemMark.getColumn()))) { |
| 63 | 10 | lines.append(contextMark.toString()); |
| 64 | 10 | lines.append("\n"); |
| 65 | |
} |
| 66 | 17 | if (problem != null) { |
| 67 | 15 | lines.append(problem); |
| 68 | 15 | lines.append("\n"); |
| 69 | |
} |
| 70 | 17 | if (problemMark != null) { |
| 71 | 15 | lines.append(problemMark.toString()); |
| 72 | 15 | lines.append("\n"); |
| 73 | |
} |
| 74 | 17 | if (note != null) { |
| 75 | 1 | lines.append(note); |
| 76 | 1 | lines.append("\n"); |
| 77 | |
} |
| 78 | 17 | return lines.toString(); |
| 79 | |
} |
| 80 | |
|
| 81 | |
public String getContext() { |
| 82 | 1 | return context; |
| 83 | |
} |
| 84 | |
|
| 85 | |
public Mark getContextMark() { |
| 86 | 1 | return contextMark; |
| 87 | |
} |
| 88 | |
|
| 89 | |
public String getProblem() { |
| 90 | 1 | return problem; |
| 91 | |
} |
| 92 | |
|
| 93 | |
public Mark getProblemMark() { |
| 94 | 1 | return problemMark; |
| 95 | |
} |
| 96 | |
} |