diff options
Diffstat (limited to 'subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/psystem/queries/PProblem.java')
-rw-r--r-- | subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/psystem/queries/PProblem.java | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/psystem/queries/PProblem.java b/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/psystem/queries/PProblem.java new file mode 100644 index 00000000..1fe4f541 --- /dev/null +++ b/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/psystem/queries/PProblem.java | |||
@@ -0,0 +1,68 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010-2014, Bergmann Gabor, Istvan Rath and Daniel Varro | ||
3 | * This program and the accompanying materials are made available under the | ||
4 | * terms of the Eclipse Public License v. 2.0 which is available at | ||
5 | * http://www.eclipse.org/legal/epl-v20.html. | ||
6 | * | ||
7 | * SPDX-License-Identifier: EPL-2.0 | ||
8 | *******************************************************************************/ | ||
9 | package tools.refinery.viatra.runtime.matchers.psystem.queries; | ||
10 | |||
11 | import tools.refinery.viatra.runtime.matchers.planning.QueryProcessingException; | ||
12 | |||
13 | /** | ||
14 | * Represents an error that was detected while the {@link PQuery} object was built from a source. | ||
15 | * @author Bergmann Gabor | ||
16 | * | ||
17 | */ | ||
18 | public class PProblem { | ||
19 | |||
20 | private final String shortMessage; | ||
21 | private final String location; | ||
22 | private final Exception exception; | ||
23 | |||
24 | public PProblem(String shortMessage) { | ||
25 | this(null, shortMessage, null, null); | ||
26 | } | ||
27 | /** | ||
28 | * @since 2.0 | ||
29 | */ | ||
30 | public PProblem(String shortMessage, Integer line, Integer column) { | ||
31 | this(null, shortMessage, line, column); | ||
32 | } | ||
33 | public PProblem(QueryProcessingException exception) { | ||
34 | this(exception, exception.getShortMessage(), null, null); | ||
35 | } | ||
36 | public PProblem(Exception exception, String shortMessage) { | ||
37 | this(exception, shortMessage, null, null); | ||
38 | } | ||
39 | |||
40 | /** | ||
41 | * @since 2.0 | ||
42 | */ | ||
43 | public PProblem(Exception exception, String shortMessage, Integer line, Integer column) { | ||
44 | this.shortMessage = shortMessage; | ||
45 | this.exception = exception; | ||
46 | if (line == null) { | ||
47 | location = "Unspecified location"; | ||
48 | } else if (column == null) { | ||
49 | location = String.format("Line %d", line); | ||
50 | } else { | ||
51 | location = String.format("Line %d Column %d", line, column); | ||
52 | } | ||
53 | } | ||
54 | |||
55 | public String getShortMessage() { | ||
56 | return shortMessage; | ||
57 | } | ||
58 | public Exception getException() { | ||
59 | return exception; | ||
60 | } | ||
61 | /** | ||
62 | * @since 2.0 | ||
63 | */ | ||
64 | public String getLocation() { | ||
65 | return location; | ||
66 | } | ||
67 | |||
68 | } | ||