Vidyashree Rama | a89bdd3 | 2016-07-08 20:45:41 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package org.onosproject.yangutils.translator.exception; |
| 18 | |
| 19 | /** |
| 20 | * Represents custom translator exception for translator's operations. |
| 21 | */ |
| 22 | public class InvalidNodeForTranslatorException extends RuntimeException { |
| 23 | |
| 24 | private static final long serialVersionUID = 20160311L; |
Bharat saraswal | 2da23bf | 2016-08-25 15:28:39 +0530 | [diff] [blame] | 25 | private transient String fileName; |
Bharat saraswal | e3175d3 | 2016-08-31 17:50:11 +0530 | [diff] [blame^] | 26 | private transient int lineNumber; |
| 27 | private transient int charPosition; |
Vidyashree Rama | a89bdd3 | 2016-07-08 20:45:41 +0530 | [diff] [blame] | 28 | |
| 29 | /** |
Bharat saraswal | 2da23bf | 2016-08-25 15:28:39 +0530 | [diff] [blame] | 30 | * Creates a new exception. |
Vidyashree Rama | a89bdd3 | 2016-07-08 20:45:41 +0530 | [diff] [blame] | 31 | */ |
| 32 | public InvalidNodeForTranslatorException() { |
| 33 | super(); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Creates a new exception with given message. |
| 38 | * |
| 39 | * @param message the detail of exception in string |
| 40 | */ |
| 41 | public InvalidNodeForTranslatorException(String message) { |
| 42 | super(message); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Creates a new exception from given message and cause. |
| 47 | * |
| 48 | * @param message the detail of exception in string |
| 49 | * @param cause underlying cause of the error |
| 50 | */ |
| 51 | public InvalidNodeForTranslatorException(final String message, final Throwable cause) { |
| 52 | super(message, cause); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Creates a new exception from cause. |
| 57 | * |
| 58 | * @param cause underlying cause of the error |
| 59 | */ |
| 60 | public InvalidNodeForTranslatorException(final Throwable cause) { |
| 61 | super(cause); |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Returns generated file name for the exception. |
| 66 | * |
| 67 | * @return generated file name for the exception |
| 68 | */ |
| 69 | public String getFileName() { |
| 70 | return this.fileName; |
| 71 | } |
| 72 | |
| 73 | /** |
Bharat saraswal | e3175d3 | 2016-08-31 17:50:11 +0530 | [diff] [blame^] | 74 | * Returns line number of the exception. |
Vidyashree Rama | a89bdd3 | 2016-07-08 20:45:41 +0530 | [diff] [blame] | 75 | * |
Bharat saraswal | e3175d3 | 2016-08-31 17:50:11 +0530 | [diff] [blame^] | 76 | * @return line number of the exception |
| 77 | */ |
| 78 | public int getLineNumber() { |
| 79 | return this.lineNumber; |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Returns position of the exception. |
| 84 | * |
| 85 | * @return position of the exception |
| 86 | */ |
| 87 | public int getCharPositionInLine() { |
| 88 | return this.charPosition; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Sets line number of YANG file. |
| 93 | * |
| 94 | * @param line line number of YANG file |
| 95 | */ |
| 96 | public void setLine(int line) { |
| 97 | this.lineNumber = line; |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Sets position of exception. |
| 102 | * |
| 103 | * @param charPosition position of exception |
| 104 | */ |
| 105 | public void setCharPosition(int charPosition) { |
| 106 | this.charPosition = charPosition; |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * Sets file name in exception. |
| 111 | * |
| 112 | * @param fileName YANG file name |
Vidyashree Rama | a89bdd3 | 2016-07-08 20:45:41 +0530 | [diff] [blame] | 113 | */ |
| 114 | public void setFileName(String fileName) { |
| 115 | this.fileName = fileName; |
| 116 | } |
| 117 | } |