Debian Codegraph @

src/main/java/ezvcard/io/json/JCardParseException.java

raw symbols SCIP
1 package ezvcard.io.json;
2
3 import java.io.IOException;
4
5 import com.fasterxml.jackson.core.JsonToken;
6
7 import ezvcard.Messages;
8
9 /*
10 Copyright (c) 2012-2023, Michael Angstadt
11 All rights reserved.
12
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions are met:
15
16 1. Redistributions of source code must retain the above copyright notice, this
17 list of conditions and the following disclaimer.
18 2. Redistributions in binary form must reproduce the above copyright notice,
19 this list of conditions and the following disclaimer in the documentation
20 and/or other materials provided with the distribution.
21
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
26 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 The views and conclusions contained in the software and documentation are those
34 of the authors and should not be interpreted as representing official policies,
35 either expressed or implied, of the FreeBSD Project.
36 */
37
38 /**
39 * Thrown during the parsing of a jCard, when a jCard is not formatted in the
40 * correct way (the JSON syntax is valid, but it's not in the correct jCard
41 * format).
42 * @author Michael Angstadt
43 */
44 public class JCardParseException extends IOException {
45 private static final long serialVersionUID = 5139480815617303404L;
46 private final JsonToken expected, actual;
47
48 /**
49 * Creates a jCard parse exception.
50 * @param expected the JSON token that the parser was expecting
51 * @param actual the actual JSON token
52 */
53 public JCardParseException(JsonToken expected, JsonToken actual) {
54 super(Messages.INSTANCE.getExceptionMessage(35, expected, actual));
55 this.expected = expected;
56 this.actual = actual;
57 }
58
59 /**
60 * Creates a jCard parse exception.
61 * @param message the detail message
62 * @param expected the JSON token that the parser was expecting
63 * @param actual the actual JSON token
64 */
65 public JCardParseException(String message, JsonToken expected, JsonToken actual) {
66 super(message);
67 this.expected = expected;
68 this.actual = actual;
69 }
70
71 /**
72 * Gets the JSON token that the parser was expected.
73 * @return the expected token
74 */
75 public JsonToken getExpectedToken() {
76 return expected;
77 }
78
79 /**
80 * Gets the JSON token that was read.
81 * @return the actual token
82 */
83 public JsonToken getActualToken() {
84 return actual;
85 }
86 }