Path: blob/master/sourcetools/objectmodel/com/ibm/j9tools/om/OMElementException.java
6004 views
/*******************************************************************************1* Copyright (c) 2007, 2019 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* 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-exception20*******************************************************************************/21package com.ibm.j9tools.om;2223/**24* Object Model exception used to describe errors in an element of a {@link OMObject}.25*26* @author Gabriel Castro27* @since v1.5.028*/29public abstract class OMElementException extends OMException {30private static final long serialVersionUID = 1L; /** Identifier for serialized instances. */3132protected int lineNumber = -1;33protected int column = -1;34protected String fileName;3536/**37* Creates an {@link OMElementException} for the given object with its associated38* error message.39*40* @param message the error message41* @param object the source of the error42*/43public OMElementException(String message, OMObject object) {44super(message);4546if (object != null && object.getLocation() != null) {47this.lineNumber = object.getLocation().getLine();48this.fileName = object.getLocation().getFileName();49this.column = object.getLocation().getColumn();50}5152this.object = object;53}5455/**56* Overwrites the error line number for this exception.57*58* @param lineNumber the line number in which the error occured59*/60public void setLineNumber(int lineNumber) {61this.lineNumber = lineNumber;62}6364/**65* Retrieves the line number for this exception.66*67* @return the line number68*/69public int getLineNumber() {70return lineNumber;71}7273/**74* Overwrites the error column number for this exception.75*76* @param column the column in which the error occured77*/78public void setColumn(int column) {79this.column = column;80}8182/**83* Retrieves the column number for this exception.84*85* @return the column number86*/87public int getColumn() {88return column;89}9091/**92* Overwrites the file name associated with this exception's object.93*94* @param fileName the new file name95*/96public void setFileName(String fileName) {97this.fileName = fileName;98}99100/**101* Retrieves the file name associated with this exception's object.102*103* @return the name of the object's file104*/105public String getFileName() {106return fileName;107}108}109110111