Class | Line # | Actions | |||
---|---|---|---|---|---|
ContentHandler | 13 | 0 | 0 |
1 | package org.json.simple.parser; | |
2 | ||
3 | import java.io.IOException; | |
4 | ||
5 | /** | |
6 | * A simplified and stoppable SAX-like content handler for stream processing of JSON text. | |
7 | * | |
8 | * @see org.xml.sax.ContentHandler | |
9 | * @see org.json.simple.parser.JSONParser#parse(java.io.Reader, ContentHandler, boolean) | |
10 | * | |
11 | * @author FangYidong<fangyidong@yahoo.com.cn> | |
12 | */ | |
13 | public interface ContentHandler { | |
14 | /** | |
15 | * Receive notification of the beginning of JSON processing. | |
16 | * The parser will invoke this method only once. | |
17 | * | |
18 | * @throws ParseException | |
19 | * - JSONParser will stop and throw the same exception to the caller when receiving this exception. | |
20 | */ | |
21 | void startJSON() throws ParseException, IOException; | |
22 | ||
23 | /** | |
24 | * Receive notification of the end of JSON processing. | |
25 | * | |
26 | * @throws ParseException | |
27 | */ | |
28 | void endJSON() throws ParseException, IOException; | |
29 | ||
30 | /** | |
31 | * Receive notification of the beginning of a JSON object. | |
32 | * | |
33 | * @return false if the handler wants to stop parsing after return. | |
34 | * @throws ParseException | |
35 | * - JSONParser will stop and throw the same exception to the caller when receiving this exception. | |
36 | * @see #endJSON | |
37 | */ | |
38 | boolean startObject() throws ParseException, IOException; | |
39 | ||
40 | /** | |
41 | * Receive notification of the end of a JSON object. | |
42 | * | |
43 | * @return false if the handler wants to stop parsing after return. | |
44 | * @throws ParseException | |
45 | * | |
46 | * @see #startObject | |
47 | */ | |
48 | boolean endObject() throws ParseException, IOException; | |
49 | ||
50 | /** | |
51 | * Receive notification of the beginning of a JSON object entry. | |
52 | * | |
53 | * @param key - Key of a JSON object entry. | |
54 | * | |
55 | * @return false if the handler wants to stop parsing after return. | |
56 | * @throws ParseException | |
57 | * | |
58 | * @see #endObjectEntry | |
59 | */ | |
60 | boolean startObjectEntry(String key) throws ParseException, IOException; | |
61 | ||
62 | /** | |
63 | * Receive notification of the end of the value of previous object entry. | |
64 | * | |
65 | * @return false if the handler wants to stop parsing after return. | |
66 | * @throws ParseException | |
67 | * | |
68 | * @see #startObjectEntry | |
69 | */ | |
70 | boolean endObjectEntry() throws ParseException, IOException; | |
71 | ||
72 | /** | |
73 | * Receive notification of the beginning of a JSON array. | |
74 | * | |
75 | * @return false if the handler wants to stop parsing after return. | |
76 | * @throws ParseException | |
77 | * | |
78 | * @see #endArray | |
79 | */ | |
80 | boolean startArray() throws ParseException, IOException; | |
81 | ||
82 | /** | |
83 | * Receive notification of the end of a JSON array. | |
84 | * | |
85 | * @return false if the handler wants to stop parsing after return. | |
86 | * @throws ParseException | |
87 | * | |
88 | * @see #startArray | |
89 | */ | |
90 | boolean endArray() throws ParseException, IOException; | |
91 | ||
92 | /** | |
93 | * Receive notification of the JSON primitive values: | |
94 | * java.lang.String, | |
95 | * java.lang.Number, | |
96 | * java.lang.Boolean | |
97 | * null | |
98 | * | |
99 | * @param value - Instance of the following: | |
100 | * java.lang.String, | |
101 | * java.lang.Number, | |
102 | * java.lang.Boolean | |
103 | * null | |
104 | * | |
105 | * @return false if the handler wants to stop parsing after return. | |
106 | * @throws ParseException | |
107 | */ | |
108 | boolean primitive(Object value) throws ParseException, IOException; | |
109 | ||
110 | } |