blob: 935f6b69e10423612b082c2dd8fb0a55e1935469 [file] [log] [blame]
Vidyashree Ramaa89bdd32016-07-08 20:45:41 +05301/*
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
17package org.onosproject.yangutils.translator.exception;
18
19/**
20 * Represents custom translator exception for translator's operations.
21 */
22public class InvalidNodeForTranslatorException extends RuntimeException {
23
24 private static final long serialVersionUID = 20160311L;
Bharat saraswal2da23bf2016-08-25 15:28:39 +053025 private transient String fileName;
Bharat saraswale3175d32016-08-31 17:50:11 +053026 private transient int lineNumber;
27 private transient int charPosition;
Vidyashree Ramaa89bdd32016-07-08 20:45:41 +053028
29 /**
Bharat saraswal2da23bf2016-08-25 15:28:39 +053030 * Creates a new exception.
Vidyashree Ramaa89bdd32016-07-08 20:45:41 +053031 */
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 saraswale3175d32016-08-31 17:50:11 +053074 * Returns line number of the exception.
Vidyashree Ramaa89bdd32016-07-08 20:45:41 +053075 *
Bharat saraswale3175d32016-08-31 17:50:11 +053076 * @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 Ramaa89bdd32016-07-08 20:45:41 +0530113 */
114 public void setFileName(String fileName) {
115 this.fileName = fileName;
116 }
117}