Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/sourcetools/objectmodel/com/ibm/j9tools/om/OMElementException.java
6004 views
1
/*******************************************************************************
2
* Copyright (c) 2007, 2019 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
21
*******************************************************************************/
22
package com.ibm.j9tools.om;
23
24
/**
25
* Object Model exception used to describe errors in an element of a {@link OMObject}.
26
*
27
* @author Gabriel Castro
28
* @since v1.5.0
29
*/
30
public abstract class OMElementException extends OMException {
31
private static final long serialVersionUID = 1L; /** Identifier for serialized instances. */
32
33
protected int lineNumber = -1;
34
protected int column = -1;
35
protected String fileName;
36
37
/**
38
* Creates an {@link OMElementException} for the given object with its associated
39
* error message.
40
*
41
* @param message the error message
42
* @param object the source of the error
43
*/
44
public OMElementException(String message, OMObject object) {
45
super(message);
46
47
if (object != null && object.getLocation() != null) {
48
this.lineNumber = object.getLocation().getLine();
49
this.fileName = object.getLocation().getFileName();
50
this.column = object.getLocation().getColumn();
51
}
52
53
this.object = object;
54
}
55
56
/**
57
* Overwrites the error line number for this exception.
58
*
59
* @param lineNumber the line number in which the error occured
60
*/
61
public void setLineNumber(int lineNumber) {
62
this.lineNumber = lineNumber;
63
}
64
65
/**
66
* Retrieves the line number for this exception.
67
*
68
* @return the line number
69
*/
70
public int getLineNumber() {
71
return lineNumber;
72
}
73
74
/**
75
* Overwrites the error column number for this exception.
76
*
77
* @param column the column in which the error occured
78
*/
79
public void setColumn(int column) {
80
this.column = column;
81
}
82
83
/**
84
* Retrieves the column number for this exception.
85
*
86
* @return the column number
87
*/
88
public int getColumn() {
89
return column;
90
}
91
92
/**
93
* Overwrites the file name associated with this exception's object.
94
*
95
* @param fileName the new file name
96
*/
97
public void setFileName(String fileName) {
98
this.fileName = fileName;
99
}
100
101
/**
102
* Retrieves the file name associated with this exception's object.
103
*
104
* @return the name of the object's file
105
*/
106
public String getFileName() {
107
return fileName;
108
}
109
}
110
111