2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.model.parser.api;
10 import java.util.Optional;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.eclipse.jdt.annotation.Nullable;
13 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
15 @Deprecated(since = "7.0.0", forRemoval = true)
16 public class YangSyntaxErrorException extends YangParserException {
17 private static final long serialVersionUID = 2L;
19 private final SourceIdentifier source;
20 private final int line;
21 private final int charPositionInLine;
23 public YangSyntaxErrorException(final @Nullable SourceIdentifier source, final int line,
24 final int charPositionInLine, final String message) {
25 this(source, line, charPositionInLine, message, null);
28 public YangSyntaxErrorException(final @Nullable SourceIdentifier source, final int line,
29 final int charPositionInLine, final String message, final @Nullable Throwable cause) {
30 super(message, cause);
33 this.charPositionInLine = charPositionInLine;
36 public final Optional<SourceIdentifier> getSource() {
37 return Optional.ofNullable(source);
40 public final int getLine() {
44 public final int getCharPositionInLine() {
45 return charPositionInLine;
48 public @NonNull String getFormattedMessage() {
49 final StringBuilder sb = new StringBuilder(getMessage());
51 sb.append(" in source ");
55 sb.append(" on line ");
57 if (charPositionInLine != 0) {
58 sb.append(" character ");
59 sb.append(charPositionInLine);
66 public String toString() {
67 return this.getClass().getName() + ": " + getFormattedMessage();