1b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov/**
211a89b445f3bde56bf07e6a0d04f0b0256dcb215Andrey Somov * Copyright (c) 2008, http://www.snakeyaml.org
3b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov *
4b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov * Licensed under the Apache License, Version 2.0 (the "License");
5b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov * you may not use this file except in compliance with the License.
6b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov * You may obtain a copy of the License at
7b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov *
8b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov *     http://www.apache.org/licenses/LICENSE-2.0
9b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov *
10b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov * Unless required by applicable law or agreed to in writing, software
11b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov * distributed under the License is distributed on an "AS IS" BASIS,
12b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov * See the License for the specific language governing permissions and
14b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov * limitations under the License.
15b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov */
16b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somovpackage org.yaml.snakeyaml.reader;
17b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov
18b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somovimport org.yaml.snakeyaml.error.YAMLException;
19b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov
20b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somovpublic class ReaderException extends YAMLException {
21b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov    private static final long serialVersionUID = 8710781187529689083L;
22e5a5aa9c8687138033e143ce926e7e97e846aa0cAndrey Somov    private final String name;
23e5a5aa9c8687138033e143ce926e7e97e846aa0cAndrey Somov    private final char character;
24e5a5aa9c8687138033e143ce926e7e97e846aa0cAndrey Somov    private final int position;
25b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov
26b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov    public ReaderException(String name, int position, char character, String message) {
27b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov        super(message);
28b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov        this.name = name;
29b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov        this.character = character;
30b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov        this.position = position;
31b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov    }
32b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov
33e5a5aa9c8687138033e143ce926e7e97e846aa0cAndrey Somov    public String getName() {
34e5a5aa9c8687138033e143ce926e7e97e846aa0cAndrey Somov        return name;
35e5a5aa9c8687138033e143ce926e7e97e846aa0cAndrey Somov    }
36e5a5aa9c8687138033e143ce926e7e97e846aa0cAndrey Somov
37e5a5aa9c8687138033e143ce926e7e97e846aa0cAndrey Somov    public char getCharacter() {
38e5a5aa9c8687138033e143ce926e7e97e846aa0cAndrey Somov        return character;
39e5a5aa9c8687138033e143ce926e7e97e846aa0cAndrey Somov    }
40e5a5aa9c8687138033e143ce926e7e97e846aa0cAndrey Somov
41e5a5aa9c8687138033e143ce926e7e97e846aa0cAndrey Somov    public int getPosition() {
42e5a5aa9c8687138033e143ce926e7e97e846aa0cAndrey Somov        return position;
43e5a5aa9c8687138033e143ce926e7e97e846aa0cAndrey Somov    }
44e5a5aa9c8687138033e143ce926e7e97e846aa0cAndrey Somov
45b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov    @Override
46b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov    public String toString() {
47b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov        return "unacceptable character '" + character + "' (0x"
48b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov                + Integer.toHexString((int) character).toUpperCase() + ") " + getMessage()
49b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov                + "\nin \"" + name + "\", position " + position;
50b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov    }
51b5f4ec3dfb1a49968ebcc1243da10af9a2dc54a2Andrey Somov}
52