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